-1

I have a textbox and i want the input for the textbox to satisfy to conditions: a) It should be a number b) It be should be greater than 5. What should be the regular expression for that?

5
  • try this. [6-9][0-9]* Commented Sep 21, 2017 at 6:15
  • you can check the number is valid or not like here : (([1-5]\d|[6-9]))$ see the test results here Commented Sep 21, 2017 at 6:19
  • 1
    @DineshSuthar How would this allow for a number such as 28? Commented Sep 21, 2017 at 6:27
  • @RahulHendawe How would this allow for a number such as 8214? Also, why the double parentheses? Commented Sep 21, 2017 at 6:27
  • Can you more spefic? Commented Sep 21, 2017 at 6:28

1 Answer 1

2

Instead of regex you can use <input type='number'... Check snippet below

 <input type="number" name="quantity" min="6" />

Sign up to request clarification or add additional context in comments.

8 Comments

Not sure why this got downvoted, I think it is a worthy answer.
@DucFilan Ya its not working if we directly enter the number.
@AarthnaMaheshwari it automatically validate the value on submit or blur event. You can check.
@DucFilan This kind of specification will be supported by the most browsers, including the old ones.
It's not supported in IE<10.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.