So, I suck terribly at regex and javascript. As such, when I realized I needed to validate a form field via jquery to ensure that at least one alpha character was used, I decided to ask you fine folks for some help.
I want to allow user to use apostrophes, spaces, dashes, periods, underscores, and alphanumeric chars in this field. They must, however, use at least one alpha character.
Here is the validator method I created, which does everything but ensure that at least one alpha char is used.
$.validator.addMethod("nameRegex", function(value, element) {
return this.optional(element) || /[^a-z/g]+/gi.test(value) || !/[^\.\'\:\-_ a-z0-9]+/gi.test(value);
}, "Name must contain at least one letter.");
Any tips/hints/insights/insults? Thanks everyone!