Asp.net textbox in Android phone with numeric keyboard selected by default

∥☆過路亽.° 提交于 2019-12-07 08:46:29

Here is my solution:

<div style="display:none"><asp:TextBox ID="txt_Phone" runat="server" /></div>
<input onblur="document.getElementById('<%=txt_Phone.ClientID %>').value = this.value" type="tel" />

Enjoy :)

Here's a slightly more elegant way:

PhoneBox.Attributes.Add("type", "tel");

This way there is only one input control and it doesn't mess up client-side validation. Also it makes it easy to assign this attribute to multiple controls (I just added a "keypad" class to the controls that I want it to apply to, then use a recursive control search method to find them all and add the attribute).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!