| |
|
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.
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>
| |
| Subscribe |
|
Submit your email address and receive
article and product notifications. Your email is safe with us.
|
|
|
|
| JavaScript Tutorials |
| Popular Tutorials |
|
| Drop down list |
| Timer function |
| JavaScript Tutorials |
|
| String |
| Array |
| Date & Time |
| Form Validation |
| Event Handling |
| Math Functions |
| Loops & structure |
| JavaScript Forum |
| Subscribe |
|
Submit your email address and receive
article and product notifications. Your email is safe with us.
|
|
|
|