On Aug 7, 2009, at 2:53 PM, Michael Lawson wrote:
yes, you can grab the value of the textbox and match it against a
regular expression
var reg = new RegExp("/[a-zA-Z]/");
if(reg.test("string"))
{
return "valid";
}
else
{
return "not valid";
}
Hey Michael,
I don't think that regular expression is going to work. If you're
using a regular expression constructor method, as opposed to a
literal, you shouldn't use the slashes. Even without the slashes, that
test will always return true as long as the string has one upper or
lower case letter from a to z.
The OP wanted to disallow numbers, so this should do it:
if ( !(/\d/).test("string") ) {
return 'valid';
} else {
return 'not valid';
}
--Karl
____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com