I am using JQuery Validation Engine library. I am trying to create a custom validation either through Regex or custom method to validate the field input.
I would suggest this validation name as custom integer validation containing integer range or some integers separated by comma(s) or combination of both.
Here is the criteria:
- can enter any integer. For e.g.
89 - can enter any integer range. For e.g.
12-18or15-18but not19-3 (range should between min to max) - can enter any combination of above two inputs separated by comma(,) only with or without spaces between comma. For e.g.
1-6, 5, 8-13, 7. But not-3-5 (not -3)or3-7-, 10 (not 7-)
I tried this custom rule:
"integerRangeComma": {
"regex": /^(([0-9]+)([\,]([0-9]+))?|([\,]([0-9]+))?)$/,
"alertText": "* Invalid floating decimal number"
},
My intended purpose to do the above validation is:
I have a list of total documents lets suppose 12. I created a text-box in the form to accept what document no, he likes to add in his profile. And the above criteria should be applied on that.
My next question would be, I also must validate that numbers entered by user do not greater than 12 (my presumption).
How can I achieve this either through creating my own custom rule or something else.
Thanks in Advance.