2009-07-24 10 views

Répondre

2
$.validator.addMethod("mustBeFoo", function(value, element) { 
    return (value.toLowerCase && (value.toLowerCase() === "foo")); 
}, 
    "Must be foo!" 
); 

Mettez partout. Tant qu'il s'exécute avant la validation, cela fonctionnera.

1

vous pouvez également correspondre à plusieurs chaînes comme celui-ci

jQuery.validator.addMethod("statecheck", function(value, element) { 
    return (value.toLowerCase && (value.toLowerCase() === "nsw" || value.toLowerCase() === "act" || value.toLowerCase() === "nt" || value.toLowerCase() === "qld" || value.toLowerCase() === "sa" || value.toLowerCase() === "tas" || value.toLowerCase() === "vic" || value.toLowerCase() === "wa")); 
}, 
    "Please enter valid state" 
); 
Questions connexes