Loading
View RSS Feed

bali

Form Validation Using JavaScript

Rating: 5 votes, 5.00 average.
Click image for larger version. 

Name:	formval.jpg 
Views:	195 
Size:	10.3 KB 
ID:	182Click image for larger version. 

Name:	formval.jpg 
Views:	195 
Size:	10.3 KB 
ID:	182
Program to Implement form validation using javascript
Code:
<html>
	<head>
		<title>FORM VALIDATION</title>
		<script type="text/javascript">
		function f1(f)
			{
				var a,b,c,d;
				a=f.t1.value;
				b=f.t2.value;
				c=f.t3.value;
				d=f.t4.value;
				if(a.length==0)
					{
					alert("username field can not remain blank");
					return false;
					}
				if(b.length>8)
					{
					alert("password should be of max of 8 characters");
					return false;
					}
				if(b!=c)
					{
					alert("password do not match");
					return false;
					}
				if(d.indexOf("@")==-1)
					{
					alert("invalid email");
					return false;
					}
			return true;
				
			}
				
		</script>

	</head>
	
	<body bgcolor=bisque text=black>
	<form name="f" method="post" action="a1.html">
	<center>ENTER USERNAME:: <input type="text" name=t1></center></br>
	<center>ENTER PASSWORD:: <input type="password" name=t2></center></br>
	<center>RETYPE PASSWORD:: <input type="password" name=t3></center></br>
	<center>ENTER EMAIL ID:: <input type="text" name=t4></center></br>
	<center><input type="submit" value="SUBMIT" onClick="return f1(this.form)"><center><br><br>
	
	
	

	</form>
	</body>
	</html>

Submit "Form Validation Using JavaScript" to Digg Submit "Form Validation Using JavaScript" to del.icio.us Submit "Form Validation Using JavaScript" to StumbleUpon Submit "Form Validation Using JavaScript" to Google

Updated 02-27-2011 at 08:04 AM by angad

Categories
Web Design

Comments

  1. prafic's Avatar
    This is simple and nice too.........
  2. Ram's Avatar
    sometimes simple things works more rapidly
  3. gauthamvit's Avatar
    Very informative. I recently stumbled across http://rindovincent.blogspot.com where there was simple JavaScript program to validate a form. I hope it will be useful for all beginners.



Disclaimer: Users of techforum4u.com are responsible for ensuring that any material they post (article, blog posts, images or other mulitimedia content) does not violate or infringe upon the copyright, patent, trademark, or any personal or proprietary rights of any third party, and is posted with the permission of the owner of such rights.Anyone who violates these rules may have their access privileges removed without warning.