php - jQuery validate remote message -


this question has answer here:

i try display error message when email used jquery validation. unfortunately there no error message, when email used. tried following:

javascript

$('#registerform').validate({     rules: {         registeremail: {             required: true,             remote: 'ajax/ajax.validateemail.php'         }     },     messages: {         registeremail: {            remote: 'e-mail taken'         }     } }); 

php

<?php header('content-type: application/json');  $stmt = $mysqli->prepare("select * members m memail = ? limit 1"); $stmt->bind_param('s', $_post['registeremail']); $stmt->execute(); $stmt->store_result(); $stmt->fetch();  if ($stmt->num_rows == 1) {     echo false; }else{     echo true; } 

what doing wrong here? in advance help!

you need echo return true or false in backend php file.

instead of

echo(json_encode(false)); 

change

echo 'false'; 

same true

example

explanation:

jquery remote method required output either true or false remote url.

if echo true there, jquery consider boolen true

and if echo false, jquery convert boolean false.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -