Change Zip Code required input based on selection
<p>i need to change the zip code for a particular country from drop down in vb.net or using javascript  I want to change the zip code requirements as Canada and US do it differently. Canada uses the format of A1A 1A1 for example if i select canada from country the zip code format it should take is A1A 1A1 and for other country it have combination of zipCodePattern = /^\d{5}[A-Z]{1}$|^\d{5}-\d{4}$/; how can i do this.</p>

<p>i have written this </p>

<p>function validateZipCode(zipcode)
     {<br>
         var country = document.getElementById("lblCountry");</p>

<pre><code>     if (country=="Canada")
      {

         var zipCodePattern = /^[A-Z}{1}[0-9]{1}[A-Z]{1}[ ]{1}[0-9]{1}[A-Z]{1}[0-9]{1}$/;
         return zipCodePattern.test(zipcode);
     }
     else 
     {
         var zipCodePattern = /^\w{6}$|^\d{5}-\d{4}$|^\d{5}$/;
         return zipCodePattern.test(zipcode);
     }
}
</code></pre>