javascript - Regex for number between 0.0 to 0.999 onkeyup -


I am trying to validate a decimal number from 0.0 to 0.9 99 or .0 to .999.

I'm trying below

  $ ('# num'). On ("keyup", function () {var value = $ (this) .val (); var regex_cell = / 0 (\\\\ [0-9] {3})? /; If (! Value.match (Regex_cell)} {this.value = this.value.replace (this.value.slice (-1), "");}}); Instead of using Regex, you can convert to float and validate it.    

var s = "0.999"; Var n = number Parallel (s); If (n> = 0 & amp; amp; amp; amp; n & lt; = 0.999) // 3 decimal position only? S.length & lt; = 4 {// valid}

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -