jquery - How to write a regex (JavaScript) for an id validation? -
this question has answer here:
basically validation simple, i'm totally new regex , need fired quickly, here goes: 1234567890
or 123456-7890
can be, obviously, number in range of 0 - 9 , length must either 10 or 11 characters.
can please show me way write function this?
function isid(id) { return /^\d{6}-?\d{4}$/.test(id); } isid("1234567890"); // true isid("123456-7890"); // true
Comments
Post a Comment