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
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
Post a Comment