Expert Answer
file.html
<html>
<head>
<title>Employee Registration Form</title>
<script type=”text/javascript” src=”mine.js”></script>
</head>
<body bgcolor=”#FFFFFF”>
<form name=”employee” action=”” onsubmit=”return valid();” method=”post”>
<table align=”center” width=40% width=”100%” cellspacing=”2″ cellpadding=”2″ border=”5″>
<tr>
<td colspan=”2″ align=”center”><b>Employee Registration Form.</b></td>
</tr>
<tr>
<td align=”left” valign=”top” width=”41%”>Employee Name<span style=”color:red”>*</span></td>
<td width=”57%”><input type=”text” value=”” name=”emp_name” size=”24″></td>
</tr>
<tr>
<td align=”left” valign=”top” width=”41%”>Employee Number<span style=”color:red”>*</span></td>
<td width=”57%”>
<input type=”text” value=”” name=”num” onkeypress=”return isNoKey(event)” size=”24″></td>
</tr>
<tr>
<td align=”left” valign=”top” width=”41%”>Address</td>
<td width=”57%”><textarea rows=”4″ maxlen=”200″ name=”S2″ cols=”20″></textarea></td>
</tr <tr>
<td align=”left” valign=”top” width=”41%”>Contact Number</td>
<td width=”57%”>
<input type=”text” value=”” onkeypress=”return isNoKey(event)” name=”fName” size=”24″></td>
</tr>
<tr>
<td align=”left” valign=”top” width=”41%”>Job Location</td>
<td width=”57%”><select name=”dropDwn”>
<option value=”Select”>Select</option>
<option value=”Kashipur”>Kashipur</option>
<option value=”Almora”>Almora</option>
<option value=”Kashipur”>Mehra Gaav</option>
<option value=”Almora”>Mysore</option>
<option value=”Kashipur”>Bihar</option>
</select></td>
</tr>
<tr>
<td align=”left” valign=”top” width=”41%”>Designation</td>
<td width=”57%”>
<select name=”dropDwn”>
<option value=”Select”>Select</option>
<option value=”System Engg”>System Engg</option>
<option value=”Sen. System Engg”>Sen. System Engg</option>
<option value=”Data Analyst”>Data Analyst</option>
<option value=”Lead Techno”>Lead Techno</option>
<option value=”Project Man.”>Project Man.</option>
</select></td>
</tr>
<tr>
<td align=”left” valign=”top” width=”41%”>Email<span style=”color:red”>*</span></td>
<td width=”57%”>
<input type=”text” value=”” name=”email” size=”24″></td>
</tr>
<tr>
<td colspan=”2″>
<p align=”center”>
<input type=”submit” value=” Submit” name=”bb”>
<input type=”reset” value=” Reset All ” name=”bb1″></td>
</tr>
</table>
</form>
</body>
</html>
mine.js
function valid() {
if (document.employee.emp_name.value == “”) {
alert(“Please fill in the ‘Your Employee Name’ box.”);
return false;
}
if (document.employee.num.value == “”) {
alert(“Enter Employee Number”);
return false;
}
alert(“sucessfully Submitted”);
if (!(/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/).test(document.employee.email.value)) {
alert(“You have entered an invalid email address!”)
return (false)
}
}
function isNoKey(evt) {
var chCode = (evt.which) ? evt.which : event.keyCode;
if (chCode != 46 && chCode > 31 &&
(chCode < 48 || chCode > 57)) {
alert(“Enter Number”);
return false;
}
return true;
}
OUTPUT: