0

Ok I have looked on a number of links regarding how to validate an input string whether it is a number and within certain range but seems like I am not understanding it clearly.

Can somebody explain me in an easy manner, considering me a novice, how using JavaScript's Regular Expressions I can validate an input string if it is a number and between the range of 1 to 5000. Input string cannot be empty and 0.

Please do explain your RegExp magic pattern.

Faisal Mq
  • 5,036
  • 4
  • 35
  • 39
  • Is there a reason why you have to use Regular Expressions and can't check the value in a regular conditional? Like `if (val >= 1 && val < 5000)`? – romellem Apr 07 '16 at 19:40
  • can you post what you have tried so far? – omarjmh Apr 07 '16 at 19:40
  • 1
    I m using a React plugin where unfortunately I have to make use of regular expression to validate a number. Search 'Subschema' on google. – Faisal Mq Apr 07 '16 at 19:42
  • 1
    [This answer](http://stackoverflow.com/a/23383708/3832970) will help you understand how to build such patterns. The [fiddle](http://jsfiddle.net/S878Y/9/) to test your pattern is also there. – Wiktor Stribiżew Apr 07 '16 at 19:45

0 Answers0