我需要为Jquery验证插件创建一个自定义规则来检查一个特定的单词。jquery验证插件自定义规则检查一个字
在这种情况下,用户必须通过在输入字段中输入单词“cat”来正确回答问题。自定义规则需要将答案定义为“猫”,我想作为一个变量,然后检查它。
我的失败尝试:
jQuery.validator.addMethod("answercheck", function(value, element) {
var password = string('hot');
return value(password);
}, "Type the correct answer");
和设置:
rules: {
input_answer{
required: true,
answercheck: true
}
messages: {
input_answer{
required: "Answer the question",
answercheck: "Your answer is incorrect"
}
任何想法?
? - 不仅如此,他们可以编辑脚本以及 –
你最好使用Ajax发送字符串到PHP页面。 –