avatar
check valid zip code by regex TypeScript
Be assumption that format is: 92064-5617 or 92064
const zipCodeRex = /(^$)|(^\d{5}$)|(^\d{5}-\d{4}$)/;
if (this.zipCodeRex.test(zipCodeVal)) {
  // Valid
} else {
  // Invalid
}
24
You need to login to do this manipulation!