我有一個小的提交表單http://wines.effectwave.com/我試圖用Jquery進行驗證。我想檢查是否有人用默認值提交表單(例如「全名」),那麼它應該提出錯誤。到目前爲止,我已經對空值和最小字符進行了驗證。但是,我如何檢查這個默認值的條件?這是我的JQuery代碼到目前爲止:Jquery輸入表單默認值驗證
// JavaScript Document
$().ready(function() {
// validate signup form on keyup and submit
$("#regform").validate({
rules: {
fname: {
required: true,
minlength: 3
},
phone: {
required: true,
minlength: 8
},
comments: {
required: true,
minlength: 5
},
email: {
required: true,
email: true
},
},
messages: {
fname: {
required: "Please enter your full name",
minlength: "Your full name must consist of at least 3 characters"
},
phone: {
required: "Please enter your phone number",
minlength: "Your phone number must consist of at least 8 characters"
},
comments: {
required: "Please provide some comments",
minlength: "Your comments must be at least 5 characters long"
},
email: "Please enter a valid email address",
}
});
});
佔位符
更多信息,據我所知,'validate'不是一個jQuery功能。所以你可能使用了一個插件。哪一個? –
他很明顯使用jquery-validate:http://jqueryvalidation.org/ – Barmar
爲什麼使用默認值而不是佔位符? – Barmar