mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2025-12-20 09:11:40 +01:00
validate: Enhanced min/max/rangeWords (in additional-methods.js) to strip html before counting; good when counting words in a richtext editor
This commit is contained in:
@@ -4,9 +4,9 @@ function methodTest( methodName ) {
|
||||
var v = jQuery("#form").validate();
|
||||
var method = $.validator.methods[methodName];
|
||||
var element = $("#firstname")[0];
|
||||
return function(value) {
|
||||
return function(value, param) {
|
||||
element.value = value;
|
||||
return method.call( v, value, element );
|
||||
return method.call( v, value, element, param );
|
||||
};
|
||||
}
|
||||
|
||||
@@ -488,6 +488,24 @@ test("time", function() {
|
||||
ok( !method("30:00"), "Invalid time" );
|
||||
});
|
||||
|
||||
test("minWords", function() {
|
||||
var method = methodTest("minWords");
|
||||
ok( method("hello worlds", 2), "plain text, valid" );
|
||||
ok( method("<b>hello</b> world", 2), "html, valid" );
|
||||
ok( !method("hello", 2), "plain text, invalid" );
|
||||
ok( !method("<b>world</b>", 2), "html, invalid" );
|
||||
ok( !method("world <br/>", 2), "html, invalid" );
|
||||
});
|
||||
|
||||
test("maxWords", function() {
|
||||
var method = methodTest("maxWords");
|
||||
ok( method("hello", 2), "plain text, valid" );
|
||||
ok( method("<b>world</b>", 2), "html, valid" );
|
||||
ok( method("world <br/>", 2), "html, valid" );
|
||||
ok( !method("hello worlds", 2), "plain text, invalid" );
|
||||
ok( !method("<b>hello</b> world", 2), "html, invalid" );
|
||||
});
|
||||
|
||||
function testCardTypeByNumber(number, cardname, expected) {
|
||||
$("#cardnumber").val(number);
|
||||
var actual = $("#ccform").valid();
|
||||
|
||||
Reference in New Issue
Block a user