I just can't get this figured out. I'm using jquery.validator.addMethod
. Currently I have the following:
jQuery.validator.addMethod("alphanumeric", function(value, element) {
return this.optional(element) || /^\w+$/i.test(value);
}, "Letters, numbers, and underscores only please");
This allows letters, underscores and numbers. But what I'd need to allow instead of underscore would be a dash (-
).
I'm very new to regex and I've been trying to figure out this simple problem but I just can't find a way to do it. Any help would be much appreciated.