0
我没有一个完美的英语,对任何错误道歉...的Javascript面膜不工作的移动
我用,我已经源泉一个JS电话/手机屏蔽码在互联网上,当我使用我的电脑访问我的网站时,它工作正常,但是当我使用手机时,代码停止工作。
这里的JS代码:
<script type="text/javascript">
function mascara(o, f) {
v_obj = o
v_fun = f
setTimeout("execmascara()", 1)
}
function execmascara() {
v_obj.value = v_fun(v_obj.value)
}
function mtel(v) {
v = v.replace(/\D/g, "");
v = v.replace(/^(\d{2})(\d)/g, "($1)$2");
v = v.replace(/(\d)(\d{4})$/, "$1-$2");
return v;
}
function id(el) {
return document.getElementById(el);
}
window.onload = function() {
id('<%= telefoneContato.ClientID %>').onkeypress = function() {
mascara(this, mtel);
}
}
</script>
这是文本字段:
<asp:TextBox ID="telefoneContato" runat="server" CssClass="form-control" placeholder="Digite seu telefone" MaxLength="14"></asp:TextBox>
几点:
- 我使用的引导+ jQuery;
- 该页面是一个网页表单,它被链接到一个MasterPage;
- 我正在使用ASP.NET;
- 我对JS没有多少经验;
- 这款手机是一款Moto G4(Android 6.0.1),我使用Chrome浏览器访问网站。
在此先感谢!
它的工作,谢谢你! –
不客气:) –