Skip to content
Advertisement

Validate Range of Numbers

I am trying to validate a comma separated list of numbers 1-384 unique (not repeating).

i.e.

  • 1, 2, 3, 5, 6, 7, 9 is valid
  • 1-3, 5-7, 9 is valid
  • 2, 2, 6 is invalid
  • 2, is invalid
  • 1, 2, 3, 4, 15, 6, 7, 385 is invalid because the last number is more than 384

I have tried the following RegEx pattern, but is not sufficient:

JavaScript

Advertisement

Answer

You can try this-

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement