- <html>
- <head><title>employee details</title>
- <script type="text/javascript">
- function validate()
- {
- if(document.myform.empcode.value=="")
- {
- alert("Please provide your employee code!")
- document.myform.empcode.focus();
- return false;
- }
- if(document.myform.Name.value=="")
- {
- alert("Please provide your name!")
- document.myform.Name.focus();
- return false;
- }
- if(document.myform.dob.value=="")
- {
- alert("Please provide your dob!")
- document.myform.dob.focus();
- return false;
- }
- if(document.myform.subject.value=="")
- {
- alert("Please provide your gender!")
- document.myform.subject.focus();
- return false;
- }
- if(document.myform.num.value=="")
- {
- alert("Please provide your mobile no!")
- document.myform.dob.focus();
- return false;
- }
- if(document.myform.EMail.value=="")
- {
- alert("Please provide your Email!")
- document.myform.EMail.focus();
- return false;
- }
- validateEmail();
- }
- function validateEmail()
- {
- var emailID= document.myform.EMail.value;
- atpos=emailID.indexOf("@");
- dotpos=emailID.lastIndexOf(".");
- if(atpos < 1 || (dotpos - atpos < 2))
- {
- alert("Please enter correct email id")
- document.myform.EMail.focus();
- return false;
- }
- return (true);
- }
- </script>
- </head>
- <body>
- <h1 align="center">Employee Details</h1>
- <form name="myform" onsubmit="return(validate())">
- <table borders="0" cellpadding="4" celllspacing="4">
- <tr>
- <th>Empcode:</th>
- <td><input type="text" name="empcode"></td>
- </tr>
- <tr>
- <th>Name:</th>
- <td><input type="text" name="Name"></td>
- </tr>
- <tr>
- <th>DOB:</th>
- <td><input type="date" name="dob"></td>
- </tr>
- <tr>
- <th>Gender:</th>
- <td><input type="radio" name="subject" value="Male">Male
- <input type="radio" name="subject" value="Female">Female</td>
- </tr>
- <tr>
- <th>Mobile No:</th>
- <td><input type="tel" size="10" name="num"></td>
- </tr>
- <tr>
- <th>E-mail:</th>
- <td><input type="text" name="EMail"></td>
- </tr>
- <tr>
- <td></td><td><input type="submit" name="Submit" value="Submit"/>
- <input type="reset" name="Reset" value="Reset"/></td>
- </table></form>
- </body>
- </html>