We are trying to mask the input field as (999) 999-9999 x9999 but I need to show x symbol if user enters 14 characters I need to make visible the x symbol.We got output as expected.
Is there any problem in this script or any better way to do this ?
JS:
$(document).delegate('#BPhone', 'keyup', function(e) {
var Textlength = $(this).val();
console.log(Textlength.length);
if (Textlength.length >= 14)
$("#BPhone").mask("(999) 999-9999 x9999");
else
$("#BPhone").mask("(999) 999-9999");
});
HTML:
<input id="BPhone" class="" type="tel" value="" maxlength="20" placeholder="">