Reputation: 41
i create registration page in php with jquery validation.i am using CDN(content delivery network) for excute jquery .when i run program it's doesn't work validation part(jquery part)if i am click submit button page will redirect next page.jquery doesn't validate.what is reason for? answer me
my code is here
<html>
<head><title>sign up</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#signup").validate({
rules:
{
name : "required",
username :"required",
password : {required : true,minlength : 5,maxlength :10},
rpassword :
{
required : true,
equalTo : "#password"
},
email_id: {required: true,email: true}
},
messages:
{
name : "please provide your name",
username : "please provide your username",
password : {required : "please enter your password",minlenth : "your password must be atleast 5 character ",maxlength : "your password must be with in 10 character"},
rpassword : {required : "please enter your confirmation password", equalTo : "Enter Retype Password Same as Password"},
email_id: {required : "please enter e-mail id" ,email:"Please enter valid email"}
},
submitHandler : function(form)
{
submitHandlerform.submit();
}
});
});
</script>
</head>
<body>
<form id="signup" action="signup.php" method="post" >
<h1> REGISTRATION </h1>
<table>
<tr>
<td align="right">
<h2><b>full name</td></h2>
<td align="left"><input type="text" name="name"></b></tr>
<tr>
<td align="right">
<h2> <b>username</td></h2>
<td align="left"><input type="text" name="username" ></b></tr>
<td align="right">
<h2> <b>password</td></h2>
<td align="left"><input type="password" name="password" id="password" ></b></td>
<tr>
<td align="right">
<h2> <b>confirmation password</td></h2>
<td align="left"><input type="password" name="rpassword" ></b></td>
</tr>
<td align="right"><h2><b>email id</td></h2>
<td align="left"><input type="text" name="email_id" ></b></td></h2>
</tr>
<tr>
<td align="right"><input type="submit" name="submit"> </td> </tr>
</table>
</form>
you have already account click <a href="index.php">here</a>
</body>
</html>
Upvotes: 0
Views: 1617
Reputation: 4739
Try this. Its working:
<html>
<head><title>sign up</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script>
$(document).ready(function(){
//$('#signup').submit( function(){
$("#signup").validate({
rules:
{
name : "required",
username :"required",
password : {required : true,minlength : 5,maxlength :10},
rpassword :
{
required : true,
equalTo : "#password"
},
email_id: {required: true,email: true}
},
messages:
{
name : "please provide your name",
username : "please provide your username",
password : {required : "please enter your password",minlenth : "your password must be atleast 5 character ",maxlength : "your password must be with in 10 character"},
rpassword : {required : "please enter your confirmation password", equalTo : "Enter Retype Password Same as Password"},
email_id: {required : "please enter e-mail id" ,email:"Please enter valid email"}
},
submitHandler : function(form)
{
submitHandlerform.submit();
}
});
//});
});
</script>
</head>
<body>
<form id="signup" action="signup.php" method="post" >
<h1> REGISTRATION </h1>
<table>
<tr>
<td align="right">
<h2><b>full name</td></h2>
<td align="left"><input type="text" name="name"></b></tr>
<tr>
<td align="right">
<h2> <b>username</td></h2>
<td align="left"><input type="text" name="username" ></b></tr>
<td align="right">
<h2> <b>password</td></h2>
<td align="left"><input type="password" name="password" id="password" ></b></td>
<tr>
<td align="right">
<h2> <b>confirmation password</td></h2>
<td align="left"><input type="password" name="rpassword" ></b></td>
</tr>
<td align="right"><h2><b>email id</td></h2>
<td align="left"><input type="text" name="email_id" ></b></td></h2>
</tr>
<tr>
<td align="right"><input type="submit" name="submit"> </td> </tr>
</table>
</form>
you have already account click <a href="index.php">here</a>
</body>
</html>
Upvotes: 1
Reputation: 5330
Add validate plugin under jquery like
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.min.js"></script>
For your information jquery validate plugin works with jquery 1.6. so update your jquery
Upvotes: 1