Reputation: 6009
I don't have much knowledge about working of regex but I have been trying to solve this from last many hours but could not get solution of it`.
regex /^[]{13,17}$/i
I have a text-box and text-box value should be greater than or equal to 13 and less than or equal to 17.
Ex.
var value - "12345678901234".(textbox value and length is 14)
if (value.match(regex)) {
alert("Correct value");
} else {
alert("error");
}
Now, length is 14, it means condition should be true. But match function always return null
. I have tried also test function, but it doesn't give desired result.
Upvotes: 1
Views: 3288
Reputation: 3044
You should specify which kind of characters has to be in the sequence:
Any character-
/^.{13,17}$/i
Digits -
/^[0-9]{13,17}$/i
Letters -
/^[A-Z]{13,17}$/i
letters, digits, underscore and dash -
/^[A-Z0-9_-]{13,17}$/i
Upvotes: 3