Zip Code 12345-6789

0
Hi guys, Zip Code is commonly 5 digit or else it must be 9 digits value with the format 99999-9999. The attribute length given 10 in the validations. In the text box user can enter 12345 (length is 5), 12345-6789 (length is 10 but shouldn't allow user to enter 10 digits , only - is accepted after 5 digits ), 123456789 (length is 9). here the problem its allowing user to enter 10 digits (of course because the zip length is 10) , How to restrict the user entering 10 digits.
asked
1 answers
0

Regular expression ^[0-9]{5}(-{0,1}[0-9]{4})?$

answered