Open lumenier1 opened 5 years ago
Hi... Your question can be resolved by the code below (using the last version jQueryMask v1.11.1):
<div class="col-xs-6 col-sm-6 col-md-4">
<div class="form-group">
<label>Combined Values</label>
<input type="text" name="combined" class="form-control">
</div>
</div>
// Mask Phones
var combinedPhonesBehavior = function (val) {
return val.charAt(0) == '+' ? '+{0}(000)000-00-00' : '+0(000)000-00-00';
},
combinedPhonesOptions = {
onKeyPress: function(val, e, field, options) {
field.mask(combinedPhonesBehavior.apply({}, arguments), options);
},
translation: { '+': { pattern: /[+]/, optional: true} }
};
$(function() {
$(':input[name=combinedPhones]').mask(combinedPhonesBehavior, combinedPhonesOptions);
});
See in action here: https://jsfiddle.net/pyetrosafe/ug18qj9m/5/
I want to pas phone numbers with different formats: '+{7}(000)000-00-00' and '8(000)000-00-00' How to do it with this mask?