這裏是example
而對於那些例如
// extend the current rules with new groovy ones
// this one requires the text "buga", we define a default message, too
$.validator.addMethod("buga", function(value) {
return value == "buga";
}, 'Please enter "buga"!');
// this one requires the value to be the same as the first parameter
$.validator.methods.equal = function(value, element, param) {
return value == param;
};
$().ready(function() {
var validator = $("#texttests").bind("invalid-form.validate", function() {
$("#summary").html("Your form contains " + validator.numberOfInvalids() + " errors, see details below.");
}).validate({
debug: true,
errorElement: "em",
errorContainer: $("#warning, #summary"),
errorPlacement: function(error, element) {
error.appendTo(element.parent("td").next("td"));
},
success: function(label) {
label.text("ok!").addClass("success");
},
rules: {
number: {
required:true,
minlength:3,
maxlength:15,
number:true
},
secret: "buga",
math: {
equal: 11
}
}
});
});
此外,在上面的例子中,圖像與文本組合件CSS
em.error {
background: url("images/unchecked.gif") no-repeat 0px 0px;
padding-left: 16px;
}
的代碼..我需要一些東西,它們分別添加 - 圖像和文本。我需要將文本顯示在字段下方的框中,並將圖像顯示在字段標籤旁邊。 – Ummul
另外,當我在字段中輸入正確的值時,我需要圖像和文本消失 – Ummul