【问题标题】:jquery validate - fail on radiojquery validate - 无线电失败
【发布时间】:2011-08-11 22:42:29
【问题描述】:

我有一个由 jquery validate 检查的表单。导致某些问题的字段如下所示:

<label>Select an Account Type<</label><br>

<input type="radio" name="accountType" value="1" id="accountType_C"><label id="accountType_C" for="accountType_C">Coder</label>
<input type="radio" name="accountType" value="0" id="accountType_S"><label id="accountType_S" for="accountType_S">Surreptitious Ninja</label>

表单中的所有其他字段都经过适当验证,但上述字段除外。不太确定我做错了什么。大约有 12 个其他字段可以毫无问题地得到验证。我已经仔细检查了重复声明的验证,但没有。

这是验证函数:

$("#regForm").validate({

    rules: {

        accountType: "required"

    },

    messages: {

        accountType: "You must select an account type"

    }

});

非常感谢!

【问题讨论】:

  • 尝试使用规则:{ accountType:{required: true} }
  • 谢谢。括号成功了!

标签: jquery jquery-validate


【解决方案1】:
$("#regForm").validate({

        rules: {

                accountType: "checked"

        },

        messages: {

                accountType: "You must select an account type"

        }

});

【讨论】:

    【解决方案2】:

    仅作记录;)

    $("#regForm").validate({
        rules: {
            accountType: { required: true }
        },
        messages: {
            accountType: "You must select an account type"
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2013-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多