...

View Full Version : Need to check for phrase



mr_evans2u
10-14-2003, 08:35 PM
When checking this form I need to make sure that either "whitelist_from" or "whitelist_to" is present and only at the beginning. Here is what I have but it is not working. Can any one help?

thanks


if (!item.value.match (/whitelist_from/)||(!item.value.match(/whitelist_to/)))
{
alert ('"whitelist_from" or "whitelist_to" must be included at the beginning');
item.focus();
return false;
}

beetle
10-14-2003, 09:00 PM
if ( /^whitelist_(?:from|to)/.test( item.value ) )

mr_evans2u
10-14-2003, 09:19 PM
thanks for the reply beetle

what is the .test refer to?

beetle
10-14-2003, 09:52 PM
test() is a method of the global RegExp object, which is exposed to any pattern. If the pattern exists in the test string, then true is returned.

mr_evans2u
10-14-2003, 10:02 PM
thanks beetle
It works great, I just didn't understand the .test
thank you :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum