I have a string sText.
sText.search(/^\d+\.\d\d$/)
I was using the above to check that a field (value=sText)has the format
#.##
which works very well.
I now need to amend this to allow only 0-9 and format .## (as above) and also to allow commas to be input. I don't need to check that the commas are in the correct place before the decimal point (would be useful but not essential), but putting commas in is optional.
User can put
1.23
23.34
234.23
23,3.34
2,234.34
I've tried many combinations but can't seem to get it right. Can anybody help? Thanks.
sText.search(/^\d+\.\d\d$/)
I was using the above to check that a field (value=sText)has the format
#.##
which works very well.
I now need to amend this to allow only 0-9 and format .## (as above) and also to allow commas to be input. I don't need to check that the commas are in the correct place before the decimal point (would be useful but not essential), but putting commas in is optional.
User can put
1.23
23.34
234.23
23,3.34
2,234.34
I've tried many combinations but can't seem to get it right. Can anybody help? Thanks.