<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Java Alert Box</title> | |
<script> | |
function add() | |
{ | |
var a=document.form.name.value; | |
var b=document.form.name1.value; | |
if(a=="" && b=="") | |
{ | |
alert("Enter Your Username and Password"); | |
} | |
if(a=="") | |
{ | |
alert("Enter Username."); | |
} | |
else if(b=="") | |
{ | |
alert("Enter Password") | |
} | |
else | |
{ | |
alert("Form has been Sucessfully Submitted"); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<form name="form" action="" method="get"> | |
Username:<input type="text" name="name"><br> | |
Password:<input type="password" name="name1"><br> | |
<button onclick="add();">Submit</button> | |
</form> | |
</body> | |
</html> | |
Monday, February 22, 2016
Simple Form Validation Example in JavaScript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment