开发者

jquery validate remote response format

开发者 https://www.devze.com 2023-02-10 17:08 出处:网络
Trying to validate nickname using the remote method rules: { nickname: { required: true, remote: \"checknick.php\"

Trying to validate nickname using the remote method

rules: {
     nickname: {
           required: true,
           remote: "checknick.php"
     }
}

And checknick is here

$name = addslashes($_POST['nickname']);

$sql="select * from names wher开发者_开发问答e nickname='$name'";
$result=mysql_query($sql);
$num_rows = mysql_num_rows($result);

if($num_rows > 0 ) {
   $valid='false';
} else {
   $valid = 'true';
}


echo $valid;

This isn't validating for me. Can anybody help me out here.


Which validation plugin are you using?

I would try json encoding the response:

echo json_encode($valid);


json_encode($valid); isnt the issue, remote uses $_GET['nickname']

0

精彩评论

暂无评论...
验证码 换一张
取 消