Thread: Decimal check
View Single Post
Old November 25th, 2004, 12:03 PM
ChrisScott ChrisScott is offline
Friend of Wrox
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post


Yep, make pDp = 2 for 2 decimal places.

\d means a decimal character in regular expression syntax, but as it's being passed to the expressions constructor as a string, it needs to be escaped and hence becomes \\d.

new RegExp creates a regular expression object and test is one of it's methods/functions - well worth checking out if you're going to do much in the way of string manipulation or validation.