I am trying to implement phone no. masking for Mobile website. And I could not use jquery mask plugin as it was not working properly in devices. Below implementation is working fine in Android Chrome Mobile Browser. But in case of Android default browser, when I try to delete all numbers using backspace key, last some(2/3) numbers/digits are not clearing. I guess this.value += "-"; is not updating some textbox property. Phone No. Format is (ex. ###-###-####)
HTML
<input id="phoneNo" type="tel" maxlength="12" placeholder="Phone"/>
JavaScript
var phoneNo = document.getElementById("phoneNo");
phoneNo.addEventListener("textInput",function(){
if(this.value.toString().length==3 || this.value.toString().length==7) {
this.value += "-";
}
});