Ray
Ray

Reputation: 884

Using JQuery Validation Plugin Remote Function - Help checking if email exists

Im trying to use the remote feature in the JQuery Validation Plugin to check to see if the email address exists. I cannot get it to return the status of it being registered. I am using the default php class provided. I am using Jquery Latest

Here is my class

<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() { alert("submitted!"); }});
$().ready(function() {

// validate signup form on keyup and submit
$("#form1").validate({
    rules: {
        user_pass: {
            required: true,
            minlength: 6
        },
        user_pass_confirm: {
            required: true,
            minlength: 6,
            equalTo: "#user_pass"
        },
        email: {
            required: true,
            email: true,
            remote: { url:"module/1.func.php",     
            type : "get",
            data : { email : function() { return $("#email").val();
 }, 
  }
  }        
        },

        terms: "required"
    },
    messages: {
        user_pass: {
            required: "Please provide a password",
            minlength: "Password must be at least 6 characters"
        },
        user_pass_confirm: {
            required: "Please provide a password",
            minlength: "Password must be at least 6 characters",
            equalTo: "Eenter the same password as above"
        },
        email: {
            required: "Enter your email address",
            email: "Enter a valid email address",


        },

        terms: "Please accept our policies"
    }
});

});

-----EDIT--ADDED 1.inc.php-----

$email = $_REQUEST['email'];
if($email=="[email protected]"){
$valid = 'false';
}else{
$valid = 'true';
}
echo $valid;
?>

-----EDIT--Changed Jquery-----

I have now changed the email rule to the following. I get "Please Fix this field" when the email is inputted if it matches.

email: { required: true, email: true, remote: "module/1.func.php" },

Upvotes: 0

Views: 1595

Answers (1)

LeeR
LeeR

Reputation: 1636

Change your remote validator to

remote: "module/1.func.php"

It already sends the email via get and send that fields value.

Upvotes: 1

Related Questions