Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 19 su 19
  1. #11
    allora ho cambiato l'id delle input file:
    codice:
    //da cosi->> <input id="phAllegato" name="file[]" type="file"/>
    
    //a cosi
    <input id="phBand" name="file[]" type="file"/>
    <input id="phStrumenti" name="file[]" type="file"/>
    <input id="phStage_plan" name="file[]" type="file"/>
    <input id="phBrani" name="file[]" type="file"/>
    
    //ed il relativo controllo è:
    if(document.formElem.phBand.value==""){
    	confirm('Prego inserisci il file della band');
    	return false;
    }
    if(document.formElem.phStrumenti.value==""){
    	confirm('Prego inserisci il file degli strumenti');
    	return false;
    }
    //etc etc...
    fin qui, funziona.

    Ora il problema sorge per quest'altro controllo che nel frattempo ho modificato,e che vorrei mi dicessi per favore, se va bene oppure è meglio come facevo prima:
    codice:
    //prima
    if (document.formElem.phBand.value  == ""){
    	valclass = 'error';
    }
    if (document.formElem.phStrumenti.value  == ""){
    	valclass = 'error';
    }
    
    //ora
    if (document.formElem.txt1.value==""||document.formElem.txt2.value=="" ||
    document.formElem.txt3.value==""||document.formElem.txt4.value=="" ) {
    	valclass = 'error';
    }
    Purtroppo, non riesco a capire come mai, se inserisco nel controllo che faccio adesso anche:
    codice:
    //questo
    document.formElem.phBand.value  == ""
    
    //e quindi il controllo adesso si amplia
    //ora
    if (document.formElem.txt1.value==""||document.formElem.txt2.value=="" ||
    document.formElem.txt3.value==""||document.formElem.txt4.value=="" ||
    document.formElem.phBand.value  == ""
    ) {
    	valclass = 'error';
    }
    Cosi facendo non mi funziona più niente...
    sbaglio qualcosa?

  2. #12
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    A) Non possono avere tutte lo stesso id (che come certamente saprai deve essere univoco)
    B) Come gli altri input, il concetto non cambia
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  3. #13
    si infatti, nel post precedente ho inserito gli id univoci, ma senza risultato...

  4. #14
    allora come hai detto te funziona..
    però mi sto incartando nel controllo che ho postato sopra.
    Questo controllo è riferito al primo pannello.
    se questa condizione è vera:
    codice:
    var valclass = 'checked';
    if(hasError){
    error = -1;
    if (document.formElem.txt1.value==""||document.formElem.txt2.value=="" ||
    document.formElem.txt3.value==""||document.formElem.txt4.value=="" ) {
    	valclass = 'error';
    }
    $('<span class="'+valclass+'"></span>').insertAfter($link);
    return error;
    mi restituisce 'error' altrimenti 'checked'.

    Poi, devo controllare il secondo pannello, dove ho le input file e al primo controllo inserisco anche questo, cosi facendo:
    E faccio cosi:
    codice:
    if(hasError){
    error = -1;
    if (document.formElem.txt1.value==""||document.formElem.txt2.value=="" ||
    document.formElem.txt3.value==""||document.formElem.txt4.value=="" ) {
    	valclass = 'error';
    }
    if(document.formElem.txtBand.value == ""){
    	valclass = 'error';
    }
    $('<span class="'+valclass+'"></span>').insertAfter($link);
    return error;
    Purtroppo cosi facendo, anche se nel primo pannello non si verifica quella condizione di 'error', trovando di seguito il secondo controllo mi restituisce sempre 'error'.
    Praticamente, dato che devo controllare 4 pannelli, vorrei differenziare i controlli, ossia, finito il primo se è tutto ok mi deve restituire 'checked', cosi per tutti gli altri...

    Puoi continuare a seguirmi per favore?
    Grazie mille :|

  5. #15
    praticamente facendo in questo modo funziona, però come al solito ti chiedo cortesemente se questo controllo si può ottimizzare, oppure va bene cosi:
    codice:
    //controllo 1°
    var valclass = 'checked';
    		
    		if(hasError){
    			error = -1;
    			if (document.formElem.txtCodBand.value  == "" || document.formElem.txtDataScad.value  == "" ||
    				document.formElem.txtOraScad.value  == ""  || document.formElem.txtOggetto.value   == "" ||
    				document.formElem.txtTipologia.value == "" || document.formElem.txtCategoria.value == "" 
    				){
    				valclass = 'error';
    			}
    		}
    		$('<span class="'+valclass+'"></span>').insertAfter($link);
    
    //controllo 2°
    if(hasError){
    			error = -1;	
    			if(document.formElem.phBand.value=="" || document.formElem.phStrumenti.value == "" ||
    			   document.formElem.phModello_domanda_concorso.value=="" || document.formElem.phModello_domanda_cantante_singolo.value == "" ||
    			   document.formElem.phArtisti.value=="" || document.formElem.phStage_plan.value == "" ||
    			   document.formElem.phContratto.value=="" ){
    			   valclass = 'error';
    			}
    		}
    		$('<span class="'+valclass+'"></span>').insertAfter($link);
    		
    		return error;
    che ne dici?

  6. #16
    no no, fermi tutti...non mi funziona per una maz.a.

  7. #17
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Boh.... io faccio fatica a capirti, pertanto lascio a chi e + esperto/intuitivo di me, comunque ti auguro di risolvere
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  8. #18
    si ti capisco....mi dispiace non saper descrivere meglio il problema, ma ci riprovo.
    Praticamente, devo eseguire prima un controllo, uscire e poi eseguire il secondo controllo, uscire...etc etc
    Con uscire,intendo non eseguire il secondo.
    Perchè facendo in questo modo, i controlli sono eseguiti sequenzialmente:
    codice:
    var valclass = 'checked';
    		
    		if(hasError){
    			error = -1;
    			if (document.formElem.txtCodBand.value  == ""){
    valclass = 'error';
    			}
    		}
    
    		$('<span class="'+valclass+'"></span>').insertAfter($link);
    return error;
    avendo verificato che non è stringa vuota, valorizzo quella valclass con 'checked'

    poi passo avanti e eseguo il controllo n°2:
    codice:
    //controllo 2°
    if(hasError){
    			error = -1;	
    			if(document.formElem.phBand.value==""){
    valclass = 'error';
    			}
    		}
    
    		$('<span class="'+valclass+'"></span>').insertAfter($link);
    return error;
    dovrebbe essere una cosa del genere.
    ma...scrivendo questi controlli come segue:
    codice:
    var valclass = 'checked';
    		
    		if(hasError){
    			error = -1;
    			if (document.formElem.txtCodBand.value  == ""){
    valclass = 'error';
    			}
    		}
    if(document.formElem.phBand.value==""){
    valclass = 'error';
    			}
    		}
    
    		$('<span class="'+valclass+'"></span>').insertAfter($link);
    return error;
    in questo modo, anche se il primo non ha valore 'error', finchè non eseguo il secondo controllo, il primo mi restituirà sempre 'error'.

    Quindi vorrei separare questi maledetti controlli, o cmq non eseguirli in maniera sequenziale..
    Spero di essermi spiegato meglio...
    abbiate pazienza..
    grazie ancora

  9. #19

    [jQuery]FancySlidingForm

    Buon pomeriggio.C'è qualcuno che ha utilizzato il form FancySlidingForm, preso qui
    http://javascript.html.it/script/ved...-sliding-form/ nell'archivio degli script di HTML?
    Praticamente, devo eseguire dei controlli, sulle input file, checkbox, text che compongono il form.Purtroppo, lo script originale di questo FancySlidingForm, controlla tutte le input, se sono diverse da stringa vuota, allora cambia lo status da 'error' a 'checked'.
    Però a me servirebbe eseguire il controllo solo su determinati input e non su tutti.
    vi posto per intero lo script.
    codice:
    $(function() {
    	/*
    	number of fieldsets
    	*/
    	var fieldsetCount = $('#formElem').children().length;
    	
    	/*
    	current position of fieldset / navigation link
    	*/
    	var current 	= 1;
        
    	/*
    	sum and save the widths of each one of the fieldsets
    	set the final sum as the total width of the steps element
    	*/
    	var stepsWidth	= 0;
        var widths 		= new Array();
    	$('#steps .step').each(function(i){
            var $step 		= $(this);
    		widths[i]  		= stepsWidth;
            stepsWidth	 	+= $step.width()+20;
        });
    	$('#steps').width(stepsWidth);
    
    /*
    	to avoid problems in IE, focus the first input of the form
    	*/
    	$('#formElem').children(':first').find(':input:first').focus();	
    	
    	/*
    	show the navigation bar
    	*/
    	$('#navigation').show();
    	
    	/*
    	when clicking on a navigation link 
    	the form slides to the corresponding fieldset
    	*/
        $('#navigation a').bind('click',function(e){
    		var $this	= $(this);
    		var prev	= current;
    		$this.closest('ul').find('li').removeClass('selected');
            $this.parent().addClass('selected');
    		/*
    		we store the position of the link
    		in the current variable	
    		*/
    		current = $this.parent().index() + 1;
    		/*
    		animate / slide to the next or to the corresponding
    		fieldset. The order of the links in the navigation
    		is the order of the fieldsets.
    		Also, after sliding, we trigger the focus on the first 
    		input element of the new fieldset
    		If we clicked on the last link (confirmation), then we validate
    		all the fieldsets, otherwise we validate the previous one
    		before the form slided
    		*/
            $('#steps').stop().animate({
                marginLeft: '-' + widths[current-1] + 'px'
            },500,function(){
    			if(current == fieldsetCount)
    				validateSteps();
    			else
    				validateStep(prev);
    			$('#formElem').children(':nth-child('+ parseInt(current) +')').find(':input:first').focus();	
    		});
            e.preventDefault();
        });
    	
    	/*
    	clicking on the tab (on the last input of each fieldset), makes the form
    	slide to the next step
    	*/
    	$('#formElem > fieldset').each(function(){
    		var $fieldset = $(this);
    		$fieldset.children(':last').find(':input').keydown(function(e){
    			if (e.which == 9){
    				$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
    				/* force the blur for validation */
    				$(this).blur();
    				e.preventDefault();
    			}
    		});
    	});
    	
    	/*
    	validates errors on all the fieldsets
    	records if the Form has errors in $('#formElem').data()
    	*/
    	function validateSteps(){
    		var FormErrors = false;
    		for(var i = 1; i < fieldsetCount; ++i){
    			var error = validateStep(i);
    			if(error == -1)
    				FormErrors = true;
    		}
    		$('#formElem').data('errors',FormErrors);	
    	}
    	
    	/*
    	validates one fieldset
    	and returns -1 if errors found, or 1 if not
    	*/
    
    function validateStep(step){
    		if(step == fieldsetCount) return;
    		
    		var error = 1;
    		var hasError = false;
    
    		$('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input:not(button)').each(function(){
    			var $this 		= $(this);
    			var valueLength = jQuery.trim($this.val()).length;
    			
    /*a questo punto, all'apertura del form lo status delle input sono vuote, colorandole di rosa altrimenti di bianco, se riempite.
    A questo punto, vorrei inserire un controllo, solo su determinate input.
    */
    			if(valueLength == ''){
    				hasError = true;
    
    				$this.css('background-color','#FFEDEF');//colore rosa
    }
    			else
    				
    				$this.css('background-color','#FFFFFF');//colore bianco
    				
    			
    		});
    		var $link = $('#navigation li:nth-child(' + parseInt(step) + ') a');
    		$link.parent().find('.error,.checked').remove();
    		
    		var valclass = 'checked';
    
    		if(hasError){
    			error = -1;
    			valclass = 'error';
    		}		
    		$('<span class="'+valclass+'"></span>').insertAfter($link);
    		return error;
    	}
    	
    	/*
    	if there are errors don't allow the user to submit
    	*/
    	$(document).ready(function() {
    	$('#registerButton').bind('click',function(){
    	if($('#formElem').data('errors')){
    return false;
    });
    });
    Se vi può essere d'aiuto, posto anche la pagina dov'è il form.
    Aiutooooooo....
    grazie mille.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.