本文介绍了通过Benjamin Keen自己的功能进行的rsv验证无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试本杰明的想法 RSV验证脚本(jQuery版本),但是具有自己的脚本功能不起作用.我的自定义函数返回false,但是oncompletehandler仍然被称为??

I am trying benjamin's keens RSV validation script (jquery version), but with an own function it doesn't work. my custom function returns false but the oncompletehandler is still called??

$("#testForm").RSV({
    onCompleteHandler: myOnComplete,
    displayType: "alert-one",
    rules: [
      "required,first_name,Please enter your first name.",
    "required,last_name,Please enter your last name.",
    "required,email,Please enter your email address.",
    "valid_email,email,Please enter a valid email address.",
      "function,testfunct",

    ]
  });




function testFunc() {
        tmpName = $('#tmpName').val();
        if (tmpName != '') {
            //alert ("name has been set");
            return true;
        }
        else {
            alert ("Credit card empt");
            $('#tmpName').focus();
            return false;
            }
     }`

推荐答案

您的自定义函数不正确.预计会返回:

Your customized function is not correct. It is expected to return:

  • 通过验证后为true.
  • 验证失败时的数组(但不是"false").

更多详细信息,请参阅其官方文件,然后单击以下项目:自定义验证规则"

more details please refer to its official document , then click the item: "Custom validation rules"

如果该字段通过了您管理的一项或多项测试,则必须显式返回true. 如果未通过测试,则必须返回一个数组数组,如下所示:

If the field passes whatever test or tests you administer, it must explicitly return true. If it fails the test(s), it has to return an array of arrays, like so:

 return [[node1, "error message1"], [node2, "error message2"], [node3, "error message3"]];

或者如果您的函数仅引发一个错误:

Or if your function is just throwing a single error:

 return [[node, "error message"]];

请注意双引号[[和]].那不是错字!

Note the double [[ and ]]. That's a not a typo!

这篇关于通过Benjamin Keen自己的功能进行的rsv验证无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 22:53