cesil << det virker fint, men nu har jeg altså et problem fordi jeg har også validering på formen der skal sendes. Nu valider den ikke den disabler bare knappen.
Her er scriptet:
<script>
function dis1() { document.getElementById('opret').disabled = true; }
</script>
<script Language="JavaScript"> <!-- function Form1_Validator(theForm) {
// Name if (theForm.Name.value == "") { alert("Du skal skrive dit navn."); theForm.Name.focus(); return (false); }
// Address if (theForm.Address.value == "") { alert("Du skal skrive din adresse."); theForm.Address.focus(); return (false); }
// PostCode if (theForm.PostCode.value == "") { alert("Du skal skrive dit postnummer."); theForm.PostCode.focus(); return (false); }
// PostCode if (theForm.PostCode.value.length < 4) { alert("Dit postnummer er ikke korrekt"); theForm.PostCode.focus(); return (false); }
// PostCode if (theForm.PostCode.value.length > 4) { alert("Dit postnummer er ikke korrekt"); theForm.PostCode.focus(); return (false); }
// PostCode var checkOK = "0123456789"; var checkStr = theForm.PostCode.value; var allValid = true; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } if (ch != ",") allNum += ch; } if (!allValid) { alert("Dit postnummer er ikke korrekt"); theForm.PostCode.focus(); return (false); }
// City if (theForm.City.value == "") { alert("Du skal skrive navnet på din by."); theForm.City.focus(); return (false); }
// MobilPhone var checkOK = "0123456789"; var checkStr = theForm.MobilPhone.value; var allValid = true; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } if (ch != ",") allNum += ch; } if (!allValid) { alert("Dit Mobilnummer er ikke korrekt"); theForm.MobilPhone.focus(); return (false); }
// HomePhone var checkOK = "0123456789"; var checkStr = theForm.HomePhone.value; var allValid = true; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } if (ch != ",") allNum += ch; } if (!allValid) { alert("Dit Telefon nummer er ikke korrekt"); theForm.HomePhone.focus(); return (false); }
// Email if (theForm.Email.value == "") { alert("Du skal skrive din E-Mail."); theForm.Email.focus(); return (false); }
// Email var checkEmail = "@."; var checkStr = theForm.Email.value; var EmailValid = false; var EmailAt = false; var EmailPeriod = false; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkEmail.length; j++) { if (ch == checkEmail.charAt(j) && ch == "@") EmailAt = true; if (ch == checkEmail.charAt(j) && ch == ".") EmailPeriod = true; if (EmailAt && EmailPeriod) break; if (j == checkEmail.length) break; } // if both the @ and . were in the string if (EmailAt && EmailPeriod) { EmailValid = true break; } } if (!EmailValid) { alert("Du skal skrive din E-Mail."); theForm.Email.focus(); return (false); }
<script Language="JavaScript"> <!-- function Form1_Validator(theForm) {
// Name if (theForm.Name.value == "") { alert("Du skal skrive dit navn."); theForm.Name.focus(); return (false); }
// Address if (theForm.Address.value == "") { alert("Du skal skrive din adresse."); theForm.Address.focus(); return (false); }
// PostCode if (theForm.PostCode.value == "") { alert("Du skal skrive dit postnummer."); theForm.PostCode.focus(); return (false); }
// PostCode if (theForm.PostCode.value.length < 4) { alert("Dit postnummer er ikke korrekt"); theForm.PostCode.focus(); return (false); }
// PostCode if (theForm.PostCode.value.length > 4) { alert("Dit postnummer er ikke korrekt"); theForm.PostCode.focus(); return (false); }
// PostCode var checkOK = "0123456789"; var checkStr = theForm.PostCode.value; var allValid = true; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } if (ch != ",") allNum += ch; } if (!allValid) { alert("Dit postnummer er ikke korrekt"); theForm.PostCode.focus(); return (false); }
// City if (theForm.City.value == "") { alert("Du skal skrive navnet på din by."); theForm.City.focus(); return (false); }
// MobilPhone var checkOK = "0123456789"; var checkStr = theForm.MobilPhone.value; var allValid = true; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } if (ch != ",") allNum += ch; } if (!allValid) { alert("Dit Mobilnummer er ikke korrekt"); theForm.MobilPhone.focus(); return (false); }
// HomePhone var checkOK = "0123456789"; var checkStr = theForm.HomePhone.value; var allValid = true; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } if (ch != ",") allNum += ch; } if (!allValid) { alert("Dit Telefon nummer er ikke korrekt"); theForm.HomePhone.focus(); return (false); }
// Email if (theForm.Email.value == "") { alert("Du skal skrive din E-Mail."); theForm.Email.focus(); return (false); }
// Email var checkEmail = "@."; var checkStr = theForm.Email.value; var EmailValid = false; var EmailAt = false; var EmailPeriod = false; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkEmail.length; j++) { if (ch == checkEmail.charAt(j) && ch == "@") EmailAt = true; if (ch == checkEmail.charAt(j) && ch == ".") EmailPeriod = true; if (EmailAt && EmailPeriod) break; if (j == checkEmail.length) break; } // if both the @ and . were in the string if (EmailAt && EmailPeriod) { EmailValid = true break; } } if (!EmailValid) { alert("Du skal skrive din E-Mail."); theForm.Email.focus(); return (false); } document.getElementById('opret').disabled = true; } //--></script>
Prøv lige at kalde din validering i cesils dis funktion function dis1() { Form1_Validator (_din_form_) document.getElementById('opret').disabled = true; }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.