Here is my code, however it is not working. May someone please help me to show me what I am doing wrong?
function emailForm()
{
var x=document.forms["contact"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
document.contact.email.style.backgroundColor = "#FFB0B0";
}else{
document.contact.email.style.backgroundColor = "#B0FFB0";
}
}//end email Form
function ageForm()
{
if (parseInt(document.contact.age.value) < 18 ||
parseInt(document.contact.age.value) > 65)
{
document.contact.age.style.backgroundColor = "#FFB0B0";
}else{
document.contact.age.style.backgroundColor = "#B0FFB0";
}
}//end of age form
<body>
<form name="contact" onsubmit="emailForm(); ageForm() " >
<p>Email:
<input type="text" name="email">
</p>
<p>Age:
<input type="text" name="age">
</p>
<p>
<input type="submit" value="Submit">
</p>
</form>
</body>
![]()



Reply With Quote

Bookmarks