I need a validate a textbox for numbers only alongwith a few special conditions. The allowed values are:
- decimal numbers >= 0 [E.g. 25]
- floating point numbers [E.g. 25.83]
- decimal numbers with comma [E.g. 1,800]
I tried this regex method. but it is obviously not the correct regex for all the conditions. Please help in getting this fixed.
function validateText(text) {
var regex = new RegExp('^[0-9]+$');
return regex.test(text);
}