[英]How to make jQuery Validator remotely trigger errorPlacement?
Can anyone please tell me how I can get the jQuery Validator to call the errorPlacement
handler when a remote
function fails? 谁能告诉我remote
功能失败时如何让jQuery验证程序调用errorPlacement
处理程序? I have provided a short example: 我提供了一个简短的示例:
Cliff Notes: According to their documents, I have to output JSON, but I must have missed something because do I just echo out json_encode, or do I provide a key like echo json_encode(array('result' => 0))
as it says in this block of text . Cliff Notes:根据他们的文档,我必须输出JSON,但是我一定错过了一些事情,因为我只是回显json_encode,还是提供像echo json_encode(array('result' => 0))
之类的键在此说的文本块 。
JS: JS:
var validator = $("form#signup").validate({
onfocousout: true,
rules: {
email: {
required: true,
email: true,
remote: {
type: "POST",
url: 'test.php',
data: {
email: function() {return $("#email").val();}
}
}
},
errorPlacement: function(error, el) {
console.log('ERR' + $(el).attr('id'));
}
}
});
PHP: PHP:
<?php
echo false; // This should allow the errorPlacement to call shouldn't it?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.