简体   繁体   English

jQuery表单验证插件:使用JSON-Data进行远程检查

[英]jQuery form validate plugin: Remote check with JSON-Data

I use the query form validate plugin ( http://jqueryvalidation.org/documentation/ ) for validating some form fields via remote check, Below is my working demo code: 我使用查询表单验证插件( http://jqueryvalidation.org/documentation/ )通过远程检查来验证某些表单字段,以下是我的工作演示代码:

username: {
    required: true,
    minlength: 3,
    maxlength: 25,
    remote: "/dir/checkvalue.php"
}

The php script echoes just false or true as a string and the validation via the plugin is working fine. php脚本以字符串形式回显falsetrue ,并且通过插件进行的验证工作正常。 For some reasons I've to change the php's output to JSON, so it would be: 由于某些原因,我必须将php的输出更改为JSON,因此它将是:

{"STATUS":false} or {"STATUS":true}

I don't know how to handle this JSON response in my js plugin conf array - any help appreciated, Thanks in advance :-) 我不知道如何在我的js插件配置数组中处理此JSON响应-感谢您的帮助,在此先感谢:-)

There are some ways you can manage what is done with the remote option ( see the documentation ), such as passing an object to remote instead of your the URL. 您可以通过一些方法来管理使用remote选项( 参见文档 )进行的操作,例如将对象传递给remote而不是URL。 That object can be any of the settings described in the jQuery documentation . 该对象可以是jQuery文档中描述的任何设置。

Unfortunately, to my knowledge, there isn't any way to modify the returned data and have that passed back to jQuery Validate. 不幸的是,据我所知,没有任何方法可以修改返回的数据并将其传递回jQuery Validate。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM