Required Fields validator in JavaScript

Saranya Boopathi
Posted by Saranya Boopathi under JavaScript category on | Points: 40 | Views : 1454
Required Fields validator in JavaScript:

function ReqvalidateForm()
{
var x=document.forms["myForm"]["firstname"].value;
if (x==null || x=="")
{
alert("Enter the Name");
return false;
}
}

<form name="myForm" action="demo_form.asp" onsubmit="return ReqvalidateForm()" method="post">
First name: <input type="text" name="firstname">
<input type="submit" value="Submit">
</form>

Comments or Responses

Login to post response