Copy

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

<html> <head> <script> function validate() { var userv=document.reg.user.value; var pswdv=document.reg.pswd.value; var emailv=document.reg.email.value; var phnv=document.reg.phno.

value; var ureg=new RegExp("^[A-z][A-z0-9_.]*$"); var phreg=new RegExp("^[1-9][0-9]{9}$"); var emailreg=new RegExp("^[A-z][A-z0-9_.]*[@][Az]+[0-9]*[.][A-z]{3}$ || ^[A-z][A-z0-9_.]*[@][A-z]+[0-9]*[.][A-z]{2}[.][A-z]{2}$ "); if(!ureg.test(userv)) { window.alert("Invalid Username"); document.reg.user.focus(); return false; } else if(pswdv.length<6) { window.alert("Password too short"); document.reg.pswd.focus(); return false; } else if(!emailreg.test(emailv)) { window.alert("Invalid E-mail address"); document.reg.email.focus(); return false; } else if(!phreg.test(phnv)) { window.alert("Invalid phone number"); document.reg.phno.focus(); return false; } return true; } function phne() { var phnv=document.reg.phno.value; var phnreg=new RegExp("^[0-9]*$"); if(!phnreg.test(phnv)) { window.alert("Enter only numbers") document.reg.phno.value=""; document.reg.phno.focus(); } } </script> </head> <body> <h3>Registration</h3> <form action="success.html" name="reg" onSubmit="return validate ()"> <pre> Name <input type="text" name="user"/><br/>

Password <input type="password" name="pswd"/><br/> E-mail Id <input type="text" name="email"/> <br/> Phone Number <input type="text" name="phno" onKeyPress=" phne()"/><br/> Select sex:<br/> Male <input type="radio" name="sex"/> Female <in put type="radio" name="sex" /> Date of Birth<input type="text" value="dd/mm/yyyy"/> Select the languages known<br/> <input type="checkbox"/>Telugu<br> <input type="checkbox"/>English<br/> <input type="checkbox"/>Hindi<br/> Address: <textarea rows="5" cols="20"></textarea><br/> <input type="submit" value="submit"/> <input type="rese t"/> </pre> </form> </body> </html>

You might also like