-1

On my home page I have a log in modal that asks for the users email address and password through a basic form. When the email address is entered I have a remote validation that checks to see if the email address is in my blacklisted table in my DB. But the remote error fires off no matter if the PHP returns false or true and will not let the form submit, even if the PHP returns true. All of the validation works correct except for the remote. I can not seem to fix this problem and I have looked all over and nothing I find can solve this problem.

Home jQuery

$(function(){
$("#frmSignIn").validate({
        rules: {
            InputEmailAddress: {
                required: true,
                email: true,
                remote:"scripts/blacklist.php"
            },  
            InputPassword: {
                required: true,
                minlength: 3,
                maxlength: 20                   
            }
        },
        messages: {
            InputEmailAddress:{
                required:"Don't forget your email address!",
                email:"Please enter a valid email address",
                remote:"This email address has been backlisted"
            },
            InputPassword:{
                required:"Please enter your password",
                minlength:"Password must be longer than 3 characters",
                maxlength:"Password can not be longet than 20 characters"
            }
        },
        submitHandler: function(){
            var data = $("#frmSignIn").serialize();
            $.post('posted.php', data, function(o){
                console.log(o);
            },'json');
        }
});
});

PHP

I will add the actual table check after I get this working

$email = $_GET['InputEmailAddress'];
$valid = true;
echo json_encode($valid);
Sparky
  • 98,165
  • 25
  • 199
  • 285
mpiazza031
  • 67
  • 1
  • 10
  • Have you seen the request response in you Firedebug or chrome developper tools, ie developper tools ... ? – mathk Jan 15 '15 at 14:34
  • Yes firebug, it returns what it is supposed to true/false but the error message in jquery still fires – mpiazza031 Jan 15 '15 at 14:39
  • If you use the `submitHandler` properly by including its `form` argument, `submitHandler: function(form){...`, you can simply do this: `$(form).serialize()` – Sparky Jan 18 '15 at 00:09

1 Answers1

-1

The problem was that remote:'scripts/blacklist.php' was in single ''

Soon as I changed it to double quotes "scripts/blacklist.php" it works fine...

If anyone knows why I would love to know so I can understand, but problem solved!

mpiazza031
  • 67
  • 1
  • 10
  • I do not understand what was the issue. Please past the code. – mathk Jan 15 '15 at 15:45
  • The issue was the remote error remote:"This email address has been blacklisted" fired no matter what. But it was apparently because the rule remote call was not in double quotes – mpiazza031 Jan 15 '15 at 15:46
  • Add the javascript that you have correct. Was it on the PHP side or Javacript. Be more precise. – mathk Jan 15 '15 at 15:50
  • I edited it it was the JS remote:"This email address has been backlisted" – mpiazza031 Jan 15 '15 at 16:13
  • The URL is already surrounded by double quotes in your OP and JavaScript does not care if it's single or double quotes. In other words, the code shown in your OP, even with single quotes, would not cause the problem you describe. Your problem was elsewhere. – Sparky Jan 18 '15 at 00:14
  • I updated the question after I figured it out – mpiazza031 Jan 19 '15 at 13:51