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

Hi,

One way is to use a regular expression - just pass the number & required decimal places to this method...
Code:
function CheckDecimal(pNum, pDp){
    return new RegExp("^\\d*\\.\\d{0," + pDp + "}$").test(pNum);
}
HTH,

Chris