jquery validation
I have some problem to execute the following jquery validation program
email: {
required: true,
email: true,
remote: "emails.php"
},
.........
in jquery validation
$.ajax($.extend(true, {
url: param,
mode: "abort",
port: "validate" + element.name,
dataType: "json",
data: "email="+data,
The above codeing executed. but my problem开发者_C百科 is how to create the emails.php. Because i dont know how to get value from js file to emails.php. Pls replay me...
iam not completely sure what you would like to accomplish using this code:
$.ajax($.extend(true, {
url: param,
mode: "abort",
port: "validate" + element.name,
dataType: "json",
data: "email="+data,
Why extend? extend merges parameter2
, 3
, ... into parameter 1
. So, jQuery basically tries to put all you parameters into the little true
.
i tried to construct an example for $.ajax
which fits your needs:
$.ajax({
url: "emails.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});
for examples on creating the server side part, have a look into the demo section of the distributed zip file:
http://jquery.bassistance.de/validate/jquery.validate.zip
Use jQuery validation plugins.
$('form').validate();
Now add email validation method
$("#email").rules('add',{remote:'check_email.php',
messages: {remote: "Email address already exist"}});
In check_email.php
if($count>0) {
echo "false";die;
}else{
echo "true";die;
}
For more you can also follow this http://php-tutorial-guide.blogspot.in/2014/03/jquery-validation.html
精彩评论