|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
javascript prob
Can anybody help me out with this script?
It seems to run as far as checking the first name text box and then it just submits the form even if the text box is blank! Heres the code: <SCRIPT language = "Javascript" type="text/javascript"> <!-- hide script from older browsers function validate() { //checks MOBILE NO to make sure it has a valid number filled in if(document.frmRegister1.txtMobileNo.value.length < 10) { alert('Please fill in Mobile Phone Number.'); document.frmRegister1.txtMobileNo.focus(); return false; } //Makes Sure a password of > 6 characters is entered if(document.frmRegister1.txtPassword.value == '' || document.frmRegister1.txtPassword.value.length < 6) { alert("Please enter a password 6 characters or more in length!"); document.frmRegister1.txtPassword.focus(); return false; } //Passwords must be the same if(document.frmRegister1.txtPassword.value == document.frmRegister1.txtPassword2.value) { return true; } else { alert("Passwords must be the same!"); document.frmRegister1.txtPassword.focus(); return false; } //Makes sure a FIRST Name is entered if(document.frmRegister1.txtFirstName.value == '') { alert("Please enter your First Name"); document.frmRegister1.txtFirstName.focus(); return false; } //Surname if(document.frmRegister1.txtSurname.value == "") { alert("Please enter your Surname"); document.frmRegister1.txtSurname.focus(); return false; } //ok to here!!-------------------- //Ensures Passwords are the same //Ensures Email Passwords are the same if(document.frmRegister1.txtEPassword.value == document.frmRegister1.txtEPassword2.value) { return true; } else { alert("Email Passwords must be the same!"); document.frmRegister1.txtEPassword.focus(); return false; } //Address1 if(document.frmRegister1.txtAddress1.value == "") { alert("Please enter your address"); document.frmRegister1.txtAddress1.focus(); return false; } //Address2 confirmation if(document.frmRegister1.txtAddress2.value == '') { if(!confirm("Are you sure you want to leave Address 2 blank?\n Hit 'ok' to continue, or hit 'cancel' to go back and make changes.")) { document.frmRegister1.txtAddress2.focus(); return false; } } } //--> </SCRIPT> |
|
#2
|
||||
|
||||
|
|
|
#3
|
||||
|
||||
|
Change the point i colored on your code ... to ""
may be it'll do.. //Makes sure a FIRST Name is entered if(document.frmRegister1.txtFirstName.value == '') { alert("Please enter your First Name"); document.frmRegister1.txtFirstName.focus(); return false; } |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > javascript prob |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|