DHTML_XML2_12

<!DOCTYPE html> <html> <head> <title>Unit 2 - Q11</title> <script type="text/javascript"> function valid() { var name=document.udetail.uname.value; var lname=document.udetail.ulname.value; var eid=document.udetail.ueid.value; var atrate=eid.indexOf("@"); var dot=eid.lastIndexOf("."); if(name=="") document.getElementById('uname').innerHTML="User Name is mandatory."; else if(name.length!=10) document.getElementById('uname').innerHTML="User Name must be 10 characters long."; else document.getElementById('uname').innerHTML=""; if(lname=="") document.getElementById('ulname').innerHTML="Last Name is mandatory."; else if(lname.length!=5) document.getElementById('ulname').innerHTML="Last Name must be 5 characters long."; else document.getElementById('ulname').innerHTML=""; if(eid=="") document.getElementById('ueid').innerHTML="Email Id is mandatory."; else if (atrate<1 || dot<atrate+2 || dot+2>=eid.length) document.getElementById('ueid').innerHTML="Invalid Email Id."; else document.getElementById('ueid').innerHTML=""; } </script> </head> <body> <br> <form name="udetail"> <table align="center"> <tr> <td> User Name </td> <td> - <input type="text" name="uname"> </td> <td> <font color="red" id="uname"></font> </td> </tr> <tr> <td> Last Name </td> <td> - <input type="text" name="ulname"> </td> <td> <font color="red" id="ulname"></font> </td> </tr> <tr> <td> Email Id </td> <td> - <input type="text" name="ueid"> </td> <td> <font color="red" id="ueid"></font> </td> </tr> </table> <p align="center"><input type="button" value="Submit" onclick="valid()"></p> </form> </body> </html>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.