Javascript jquery.validate不显示消息
似乎无法找出我的jquery.validate脚本没有显示消息的原因。有人知道我做错了什么吗 尝试在单独的div中显示消息: html:Javascript jquery.validate不显示消息,javascript,jquery,Javascript,Jquery,似乎无法找出我的jquery.validate脚本没有显示消息的原因。有人知道我做错了什么吗 尝试在单独的div中显示消息: html: 您有一个未关闭的字符串文本,而且在fiddle jQuery中也没有包含 $(document).ready(function() { $('#commentForm').validate({ errorLabelContainer: "#error-note", wrapper: "li", onfo
您有一个未关闭的字符串文本,而且在fiddle jQuery中也没有包含
$(document).ready(function() {
$('#commentForm').validate({
errorLabelContainer: "#error-note",
wrapper: "li",
onfocusout: function(element, event) {
this.element(element);
},
rules: {
vehiclePrice: 'required',
estimatedTaxesAndFees: 'required'
},
messages: {
vehiclePrice: 'Please enter vehicle price',
estimatedTaxesAndFees: 'Please enter taxes and fees'//closing ' was missing
}
});
});
演示:
如果您清除文本框的内容/或向表单添加提交按钮/或手动调用表单的
valid()
方法,则将触发验证。如果您有未关闭的字符串文本,并且在FIDLE jQuery中未包含
$(document).ready(function() {
$('#commentForm').validate({
errorLabelContainer: "#error-note",
wrapper: "li",
onfocusout: function(element, event) {
this.element(element);
},
rules: {
vehiclePrice: 'required',
estimatedTaxesAndFees: 'required'
},
messages: {
vehiclePrice: 'Please enter vehicle price',
estimatedTaxesAndFees: 'Please enter taxes and fees'//closing ' was missing
}
});
});
演示:
如果清除文本框的内容/或向表单添加提交按钮/或手动调用表单的valid()
方法,将触发验证
2) 将提交按钮添加到HTML:
<input type="submit" value="Submit" />
您需要将
name
属性添加到input
以在此处获取自定义消息:
<input type="text" class="form-control" name="vehiclePrice" id="vehiclePrice"
<input type="text" class="form-control" name="estimatedTaxesAndFees"
1)将jQuery包含在您的小提琴中
2) 将提交按钮添加到HTML:
<input type="submit" value="Submit" />
您需要将name
属性添加到input
以在此处获取自定义消息:
<input type="text" class="form-control" name="vehiclePrice" id="vehiclePrice"
<input type="text" class="form-control" name="estimatedTaxesAndFees"
表单中没有提交按钮?此处缺少end qoute估计税费:'请输入税费
?此表单没有提交。它是多部分表单的一部分,用于更新div中的内容。没有确定的提交。表单中没有提交按钮?此处缺少结束qouteestimatedTaxesAndFees:“请输入税费”
?此表单没有提交。它是多部分表单的一部分,用于更新div中的内容。没有确定的提交。抱歉,应该指定。我可以得到“此字段是必需的,但它没有显示消息json中列出的唯一消息。抱歉,应该指定。我可以得到”此字段是必需的,但它没有显示消息json中列出的唯一消息。此表单没有提交。这是更大表单体验的一部分,但字段只是更新数据。我可以得到“thisfieldisrequired”一般消息(在我添加jquery…doh之后),但它没有显示唯一的消息。我更新了我原来的小提琴,就是这样。我总是忘记jquery.validate中的名称非常重要。。。谢谢。在我的例子中,我在验证之前添加了代码:e.preventDefault();因此无法验证。此表单没有提交。这是更大表单体验的一部分,但字段只是更新数据。我可以得到“thisfieldisrequired”一般消息(在我添加jquery…doh之后),但它没有显示唯一的消息。我更新了我原来的小提琴,就是这样。我总是忘记jquery.validate中的名称非常重要。。。谢谢。在我的例子中,我在验证之前添加了代码:e.preventDefault();因此它无法验证。