Numeric validation with RegExp to prevent invalid user input
I am new to regex.
Use this regular expression:
Rather than using a RegEx and taking care of all permutations of a float number, I would suggest following code to check if it is a valid float number:
var s = ".45"; var d = parseFloat(s); if (!isNaN(d)) alert("valid float: " + d);
If you have to have a regex then I would suggest:
Check out the example here for floating point number regex samples...