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>