JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://jquery-joshbush.googlecode.com/files/jquery.maskedinput-1.2.2.js"></script>
Phone: <input class="phone"/><br/>
Zip: <input class="zip"/>
<select id="country" name="country" class="country">
<option selected="selected" value="0"></option>
<option value="CA">Canada</option>
<option value="US">United States</option>
</select>
<input type="text" class="postal_code" name="postal_code" />
JavaScript
$(".phone").mask("(999)-999-9999");
$(".zip").mask("99999?-9999");
$('#country').change(function () {
//alert($('#country option:selected').val());
if ($('#country option:selected').val() == 'US') {
$(".postal_code").unmask("")
$(".postal_code").mask("99999");
//alert(' yea ');
} else {
$(".postal_code").mask("a9a-9a9");
}
});