开发者_高级运维I want to validate that the inputted data, contains a phrase, such as '%TAG%'. So, if %TAG% is not present within the text, it doesn't validate.
Any ideas how I can do this using the jQuery validation plugin? Thanks!
First Add a method to the validator
$.validator.addMethod("checkTAGPhrase", function(value, element) {
return (/%TAG%/.test(value));
}, "Invalid.");
Next use this validation class on your input element
<input type="text" name="myInput" class="checkTAGPhrase">
精彩评论