| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
||||
|
||||
|
Client Side Data Validation Example
<HTML>
<BODY BGCOLOR=#C3C3C3> <!--Client Side Validation--> <SCRIPT LANGUAGE=JAVASCRIPT> function validate(form) { //Data validation using object names to // reference objects if (form.USERID.value == "") { alert("You must enter a User ID"); form.USERID.focus() return false; } if (form.PSW.value == "") { alert("You must enter a Password"); form.PSW.focus() return false; } if (form.PSW.value != form.CPSW.value) { alert("Password and Password Confirmation Did Not Match"); form.CPSW.focus() return false; } return true; } function validate2(form) { //Data validation using elements[] to re // ference objects if (form.elements[0].value == "") { alert("You must enter a User ID"); form.elements[0].focus() return false; } if (form.elements[1].value == "") { alert("You must enter a Password"); form.elements[1].focus() return false; } if (form.elements[1].value != form.elements[2].value) { alert("Password and Password Confirmation Did Not Match"); form.elements[1].focus() return false; } return true; } </SCRIPT> <FORM onSubmit="return validate(this)" ACTION="http://www.truegeeks.com" METHOD=post> <TABLE><TR> <TD ALIGN=right><STRONG><FONT color=#000080>USER ID:</FONT></STRONG></TD> <TD><INPUT TYPE=TEXTBOX NAME=USERID SIZE=25 MAXLENGTH=25></TD></TR> <TR> <TD ALIGN=right><FONT color=#000080><STRONG>PASSWORD:</STRONG></FONT></TD> <TD><INPUT TYPE=password NAME=PSW SIZE=25 MAXLENGTH=25></TD></TR> <TR> <TD ALIGN=right><FONT color=#000080><STRONG>CONFIRM PASSWORD:</STRONG></FONT></TD> <TD><INPUT TYPE=password NAME=CPSW SIZE=25 MAXLENGTH=25></TD></TR> <TR><TD><TD><INPUT TYPE=submit VALUE="Submit 1"></TD></TR> </TABLE></FORM> </BODY></HTML> |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Client Side Data Validation Example |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|