I’m using the jquery validator plugin and I want to add a custom method that checks to see if the user inputted a certain keyword. If they didn’t then they can’t continue, kind of like a password. There are multiple keywords they could enter, they just need to enter one of them and they can move on. I also want to remove any whitespaces they might enter in. Here’s what I have so far:
jQuery.validator.addMethod("code", function(value, element) {
return this.optional(element) || /^\bCODE1\b+\bCODE2\b+\bCODE3\b$/i.test(value);
}, jQuery.format("Please enter a correct code"));
This isn’t working like I want it to, how should I change it to make it work? Thanks
How about:
Example: http://jsfiddle.net/shv7h/