form validation (client side) using jquery

A

Anonymous

Guest
Here is the code:

<html>
<head>
<title>login page validation using jQuery</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">

</script>
<script type="text/javascript">
$(document).ready(function(){
$('#submit').click(function(){
var username=$('#email').val();
var password=$('#password').val();

if(username=="")
{
$('#msg').slideDown().html("<span>Please type Username</span>");
return false;
}
if(password=="")
{
$('#msg').slideDown().html('<span id="error">Please type Password</span>');
return false;
}
});
});
</script>
</head>
<body>

<fieldset style="width:250px;">
<form method="post" action="index.php">
Log-in page validation (client side) using jQuery

<div id="dis"></div><br>
Username: <input type="text" name="email" id="email" /><br />
Password: <input type="password" name="password" id="password" /><br /><br />
<center><input type="submit" name="submit" id="submit" /></center>
</form>

</fieldset>
</body>
</html>
 
Back
Top