Required Fields validator in JavaScript

Saranya Boopathi
Posted by Saranya Boopathi under JavaScript category on | Points: 40 | Views : 798
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">

Comments or Responses

Login to post response