[thelist] numeric only regex? [ and one more perhaps?]

Chris at globet.com Chris at globet.com
Wed Aug 3 08:14:09 CDT 2005


Tom

[..]

> - Minimum 3 characters
> - Alpha only
> - We must allow a wildcard character of "*"
> 
> So valid would be: abc, abc*, abcde etc
> and invalid input: ab*, ab, 1a*, 1a
> 
> For that we are using:
> ---
> if (nametext.value.length > 0) {
>         var noWildCards = nametext.value.split("*");
>         if (noWildCards[0].length < 3) {
>             alert("The customer search criteria must have at 
> least 3 characters (and may also have optional 
> wildcards).\nYou entered: "+nametext.value);
>             return false;
>         }
>     }

What about the following:

var namematch = /^[a-zA-Z\*]{3,}$/.test(nametext.value);

I haven't had time to test it, but in principle it should provide you
with what you require.

Chris Marsh
Web Developer
http://www.globet.com/
Tel: +44 20 8246 4804 Ext 828
Fax: +44 20 8246 4808

Any opinions expressed in this email are those of the individual and not
necessarily the Company. This message is intended for the use of the
individual or entity to which it is addressed and may contain
information that is confidential and privileged and exempt from
disclosure under applicable law. If the reader of this message is not
the intended recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly prohibited.
If you have received this communication in error, please contact the
sender immediately and delete it from your system. 


More information about the thelist mailing list