SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Javascript Form Validation

We can validate the entry of any form by using JavaScript. This is a client side JavaScript form validation and you can check server side php form validation also. Before taking up any client side validation it is advisable to check JavaScript is not disabled in the client browser.


You can see a demo of Form Validation here.




Notice how you are prevented from submitting form unless the text input field is filled.


Input :


Here is the sample source code of the above demo

<html>
<head>
<title>Javascript Form Validation</title>
<script language='JavaScript' type='text/JavaScript'>
<!--
function validate() {
	if(document.form1.textinput.value=='')
		{
		alert('Fill the Input box before submitting');
		return false;
		}
	
	else	{
		return true;
			}
}
//-->
</script>
</head>
<body>
<form name='form1' action='javascript_validation.php' method='post' 
				onSubmit='return validate();'>
Input :<input type=text name=textinput value=''>
<input type=submit value=submit>
</form>
</body>
</html>
Next read validation of period button

Found anything wrong or wants to improve the code by adding more features? Post your short comment here or use the Forum



Further readings
Disabling the submit button till all the elements of the form are validated
getElementById to access form elements with event handlers
Javascript Form Validation
Period button Validation of a form
How to limit number of checkboxes allowed to be clicked inside a form
Checkbox Validation of a form
Displaying checked value of a check box array
disabling checkbox by button click
disabling Period button by a checkbox
Enable or disable of a text box by a checkbox
All Checking & Un checking in a group of checkboxes by single button
Adding options to a drop down list box
Removing options from a drop down list box
Moving options from one drop down list box to other
Dynamic population of second list box based on value of first list box

Join Our Email List
Email:  
For Email Newsletters you can trust
Form
Form validation
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2013 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer