regex - Detect Floating point input using javascript regular expression -
i need find whether number inputed user valid next cases valid
1. `12` 2. `12.01` the next case invalid:
1. `12.` // decimal point no number next i have written regular look
var decimalvalidation = /^[0-9]*(\.?)[0-9]*$/; var n = decimalvalidation .test(value); but problem accepts value 12.
change regex below match both integer , floating point numbers.
var decimalvalidation = /^\d+(?:\.\d+)?$/; demo
javascript regex
No comments:
Post a Comment