I'm trying to validate an input field to accept x OR x+y where x and y are whole numbers from 1-10. Which regular expression matches this? This is to be used with custom jQuery validation.
Examples
This should do it (assuming your "1-10" was inclusive of both ends):
^([1-9]|10)(\+([1-9]|10))?$
http://rentzsch.github.com/JSRegexTeststand/ is your friend here.
This one should do the trick
/^([1-9]|10)(\+([1-9]|10)){0,1}$/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With