Try this:-
Code:
function test(value){
var patt1;
if(value.indexOf(".")==-1){
patt1=new RegExp("^[0-9]{1,18}$");
}else{
patt1=new RegExp("^[0-9]{1,18}(\.[0-9]{1,5})?$");
}
if(patt1.test(value)){
alert('Successful');
}else{
alert('No Match');
}
}
I found it was the + that was causing the problem. I also found that if you didn't include a decimal point, it allowed you to add mor ethan 18 numbers. Not sure why that happened, but I tried the above and it seemed to work.
You might want to make a few changes to fit in with your code. I just had it firing on a button click which passed the value of a textbox to the function.
Hope that helps.
Bookmarks