I'd like to evaluate a form field using a regex.
What expression do I use to actually compare the value to the regex?
I'm imagining something thus:
if($('#someID').val() == /someregex/) {doSomething()}
But that doesn't work. Any advice?
Note that there is no value() method in jQuery, you need to use val() and match like this:
if($('#someID').val().match(/someregex/) {
// success
}
More Info:
use the match method of the strings..
string.match(regexp)
so in your case
if( $('#someID').value().match(/someregex/) ) {doSomething()}
Something like:
if (/myRegExp/.test($('#myID').val()) {
//... do whatever
}