Core JavaScript

Intermediate JavaScript

JavaScript Reference

JavaScript Form Validation




What is JavaScript Validation?
JavaScript is use to validate form data in HTML documents before send to server. Check the required field is missing or not, check the email address is valid or not etc.


JavaScript Form Validation Syntax

function form_validate()
{
  var value; // variable declaration assign form value
  if (value==null || value=="")
    {
    alert(alert_Message);
    return false;
    }
  else
    {
    return true;
    }
}

JavaScript Form Validation Logic:

function form_validate()
{
	var val=document.forms["check_form"]["ur_name"].value
	if (val==null || val=="")
  	{
  		alert("Name must be Required..!");
 		return false;
  	}
}

JavaScript Form Validation:

Example-Code:

<script type="text/javascript">
function form_validate()
{
	var val=document.forms["check_form"]["ur_name"].value
	if (val==null || val=="")
  	{
  		alert("Name must be Required..!");
 		return false;
  	}
    else
    {
    	alert("Successful Validation..!");
    }
}
</script>

<form mane="check_form" action="form_submit_message.php" method="post"
onsubmit="return form_validate();">
Enter Your Full Name:
<input type="text" name="ur_name" size="35">
<input type="submit" value="Submit">
</form>
Online Try This Code Your Self....   »

Example-Result:

Enter Your Full Name: