屏蔽电话号码的文本框视图

编程入门 行业动态 更新时间:2024-10-17 18:12:21
本文介绍了屏蔽电话号码的文本框视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试格式化文本框,以便当用户输入电话号码时,它会自动将其放入以下格式:(999)999-9999

i am trying to format a text box so that when the users can type in a phone number and it would automatically put it in the following format :(999)999-9999

我尝试使用 MaskedEditExtender,它可以工作,但与我需要的完全相反.

i tried using the MaskedEditExtender, it works but it does the complete opposite of what i need.

当我点击该字段时,它会显示正确的格式,但是一旦我将鼠标移开,它仍然只显示 9999999999

when i click on the field it shows the correct format, but once i mouse out it still only shows 9999999999

我怎样才能做到让用户只输入数字并在它应该自动(现在这样做)的地方放置破折号和括号,但当我点击它时保持格式.

how can i do it so that the user ONLY types in numbers and it puts dashes and parentheses where it's supposed to automatically(which it does now), but keep the format when i click out of it.

<asp:TextBox ID="txtSuperPhone" runat="server" CssClass="myinputstyle" /> <asp:MaskedEditExtender ID="mskSuperPhone" runat="server" TargetControlID="txtSuperPhone" Mask="(999)999-9999"/>

推荐答案

要回答您的问题,您必须在扩展器上将ClearMaskOnLostFocus"设置为 false 以使蒙版始终显示.

To answer your question, you have to set the "ClearMaskOnLostFocus" to false on the extender for the mask to show all the time.

话虽如此....

我强烈建议您使用 jquery 替代方案.

I strongly suggest that you use the jquery alternative.

digitalbush/projects/masked-input-plugin/

我之所以这么说是因为 maskededitextender 在 safari 中不起作用.

The reason I say this is because the maskededitextender does not work in safari.

更多推荐

屏蔽电话号码的文本框视图

本文发布于:2023-11-24 23:20:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627311.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   屏蔽   文本框   电话号码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!