This can be achieved through javascript validation.please see the below function
HTMLInputElement.prototype.maskPhoneNumber = function maskPhoneNumber(readOnlyStart, readOnlyEnd) {
this.addEventListener('keydown', function (event) {
var which = event.which;
if (((which == 8) && (this.selectionStart <= readOnlyEnd && this.selectionStart >= readOnlyStart)) ||
((which == 46) && (this.selectionStart < readOnlyEnd))) {
event.preventDefault();
}
});
this.addEventListener('keypress', function (event) {
var which = event.which;
if ((event.which != 0) && (this.selectionStart < readOnlyEnd && this.selectionStart > readOnlyStart)) {
event.preventDefault();
}
});
}
and call the function
document.getElementById("txt_mobile").maskPhoneNumber(0, 6);
html
<input type="text" id="txt_mobile" value="(971)-" />