title: asp.net How to set textbox length based on dropdownlist selection? C#
body: <p>The drop down list contains three countries, How do you set the minimum number of digits to be entered in the postcode text-box based on what country is selected. 
  For example, if user selects America, then the postcode text-Box should be set to "[0-9]{6}". But if they select Australia then the post code should be "[0-9]{4}".</p>
  
  <pre><code>    &lt;asp:DropDownList ID="dropDownList" runat="server"&gt;
      &lt;asp:ListItem  Value="-1"&gt;Country&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;America&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;Australia&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;Sweden&lt;/asp:ListItem&gt;
      &lt;/asp:DropDownList&gt;
  
      &lt;asp:RequiredFieldValidator ID="RequiredFieldValidateCountry"    
      initialValue="-1"
      ForeColor="Red" 
      runat="server"
      ErrorMessage="Please choose Country" 
      ControlToValidate="dropDownList"/&gt;
  
      &lt;asp:Label ID="Label1" runat="server" Text="PostCode"&gt;&lt;/asp:Label&gt;
      &lt;asp:textbox id="TextBox1" runat="server" &gt;&lt;/asp:textbox&gt;
      &lt;asp:CustomValidator id="CustomValidator1" runat="server" 
      OnServerValidate="TextValidate" 
      ControlToValidate="TextBox1" 
      ErrorMessage="Invalid postcode."&gt;
      &lt;/asp:CustomValidator&gt;
  
      &lt;asp:Button ID="BtnNext" runat="server" Text="Next" /&gt;
  </code></pre>