0

I am trying to figure out how to write JavaScript regex validating zip code for Cali and Virginia. This is for a webform application.

  • California Zip Code 90001-96162
  • Virginia Zip Code Ranges: 20040-20167 and 22001-24658

I have read that regex isn't the best way to do this and I agree. Yet I have limitations because of a cyber security system we use only allows this language.

Current code: ^((?!90000)(([9-9][0-6][0-1][0-6][0-2])|([9-9][0-5][0-9][0-9][0-9])|([9-9][0-6][0-0][0-9][0-9])|([9-9][0-6][0-1][0-5][0-9])))$ - Any string of 5 digits. Use custom validation to restrict the range of numbers for a zip code.

0 Answers0