wrote:
> Thanks, the code worked.
>
> I was just wondering, if you could explain how the syntax of the test
> is actually constructed? I would be highly appreciative.
>
> Regards
Apologies to Ivo...
Regular expression:
/ ---> delimeter (like quotes for a string, marks start & end)
^ ---> pattern must start at very beginning of sample string
\d ---> metacharacter, matches one digit (0-9)
+ ---> quantifier, specifies one or more of the preceding
(and replaces the {8}, which specifies exactly eight;
{3,8}, e.g., would require between 3 and 8; {2,} requires at least two
or more; '*' signifies zero or more, '?' is zero or one (i.e.,
optional)
$ ---> pattern must match to the end of sample string
/ ---> closing delimeter
So: this will match a string that contains one or more digits. And
nothing else. The exclamation mark before the call to test() 'flips'
the result: if the test fails, false becomes true, which triggers the
error message, etc.
http://www.webreference.com/js/column5/index.html