Validate us zip code Javascript

var isValidZip = /(^d{5}$)|(^d{5}-d{4}$)/.test(zip);
if(isValidZip==false)

alert(“Invalid zip”);

 

Share