Here is my html code with javascript validations…. HTML elements are showing well javascript function is not working…..
<html>
<head>
<title>SIGNUP</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function valid(fname,sname,login,name,tstest,mailf,mails){
var namef=fname.value;
var names=sname.value;
var logn=login.value;
var name1=name.value;
var ts=tstest.value;
var mailf=mail1.value;
var mails=.mail2.value;
if(namef=="") <!-- validating the field first name-->
{
window.alert("please enter name.");
fname.focus();
}
else if(names=="")<!-- validating the field second name-->
{
window.alert("please enter password");
sname.focus();
}
else if(names<=6)
{
window.alert("Password should be more than 6 characters");
sname.focus();
}
else if(logn=="")<!-- validating the login field-->
{
window.alert("please enter email.");
login.focus();
}
else if(name1=="")<!-- validating the password field-->
{
window.alert("please enter confirm password.");
name.focus();
}
else if(name1!=names)
{
window.alert("Password Mismatch");
name.focus();
}
else if(ts=="")<!-- validating the date field-->
{
alert("please enter contact number.");
tstest.focus();
}
else if(ts<10)
{
alert("Contact Number Should be Minimum 10 numbers");
tstest.focus();
}
else if(mailf=="")<!-- validating the mail field-->
{
alert("please enter qualification.");
mail1.focus();
}
else if(mails=="")<!-- validating the 2nd mail field-->
{
alert("please enter interested in.");
mail2.focus();
}
}
}
</script>
</head>
<body>
<center>
<div id="border"><div id="header">
<div id="logo-bg">
<div class="name">Ayansys</div>
<div class="tag">COMPANY SLOGAN</div>
</div>
</div>
<div>
<h1>SIGNUP FORM</h1>
<form name="sign" onsubmit="valid(fname,sname,login,pwd,tstest,mail1,mail2)" >
<table name="signuptable">
<tr><td>FIRST NAME</td><td><input type="text" name="fname" size="50"/></td></tr>
<tr><td>LAST NAME</td><td><input type="text" name="sname" size="50"/></td></tr>
<tr><td>DESIRED LOGIN NAME</td><td><input type="text" name="login" size="50"/></td></tr>
<tr><td>PASSWORD</td><td><input type="password" name="pwd" size="50"/></td></tr>
<tr><td>RE-TYPE PASSWORD</td><td><input type="password" name="repwd" size="50"/></td></tr>
<tr><td>GENDER</td><td><input type="radio" name="gender" value="Male"/>Male<input type="radio" name="gender" value="FeMale"/>Female</td></tr>
<tr><td>DATE OF BIRTH</td><td><form name="tstest">
<input type="text" readonly size="47" name="timestamp" value="">
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
</form></td></tr>
<tr><td>MAIL ID</td><td><input type="text" name="mail1" size="30">@<input type="text" name="mail2" size="11"></td></tr>
<tr><td>EMPLOYEE ID</td><td><input type="text" name="eid" size="50"></td></tr>
<tr><td>TYPE OF USER</td><td><input type="radio" name="manager"/>Manager<input type="radio" name="manager"/>SeniorManager</td></td></tr>
<tr><td>ADDRESS</td><td><textarea rows="9" cols="40" name="addr"></textarea></td></tr>
<tr><td>MOBILE NUMBER</td><td><input type="text" size="50" name="mobile"></td></tr>
<tr><td></td><td><input type="submit" name="sign" value="SUBMIT"> <input type="reset" name="cancel" value="CANCEL"/></td></tr>
</table>
</div>
</form>
</br><div>Designed by:<a href="#">STUDY CENTER</a></div>
</div>
</center>
</body>
line 13, you have a “dot”
mails=.mail2.value;line 66 syntax error you had a wrong placed brace
try removing the dot and the brace and see if it works as expeted
pulse
window.alert(), you only need to usealert()and your redeclaring you variables
your onsubmit argument
mail2differs from the expeted onemails