Ciao tutti avrei necessità, se mi potete aiutare, di una funzione che controlli che ci siano solo numeri in 5 campi.
Tenete anche presente che devo implementare questa funzione in una che già utilizzo e che contolla il riempimento di altri campi dello stesso form tra questi campi che sono tutti input test c'è anche una combo
questo è il codice:
codice:function checkform(){ var myBool; myBool = true; for (var i = 0; i <= (document.forms[0].elements.length -1); i++) { var classe = document.forms[0].elements[i].className; if (classe == "Obbligatorio") { var nome = document.forms[0].elements[i].name; var id = document.forms[0].elements[i].id; var valore = document.forms[0].elements[i].value; if (valore ==""){ alert ("Le champ " + id + " est obligatoire !"); document.forms[0].elements[i].focus(); myBool = false; break; } if(document.forms[0].dprestazione && document.forms[0].dprestazione.type=="select-one" && document.forms[0].dprestazione.selectedIndex == 0) { alert("Le champ prestations est obligatoire !"); document.forms[0].dprestazione.focus(); return false; }else{ if ((id=="e-mail") && (valore !=="")){ var rslt = valore.match("@"); if (rslt == null){ alert ("Qu'il insère correctement le champ E-mail"); document.forms[0].elements[i].focus(); myBool = false; break; } } } } } return myBool; }

Rispondi quotando