如何从文本框中删除特定文本,同时保持剩余文本完整
我试图替换模糊文本中的文本,因此如果用户输入:
Hello/test
我希望将其替换为:
test
我使用基本文本框:
<asp:TextBox runat="server" ID="fullName" CssClass="textBoxes"></asp:TextBox>
使用 asp.net 4.0 和 jquery。
我怎样才能做到这一点?
谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您希望它的功能仅保留
/
之后的字符串值,而不仅仅是简单地替换“Hello/”,请尝试以下操作:小提琴示例
Assuming the functionality you want it to only keep the value of the string after the
/
, not just to simply replace the 'Hello/', try this:Example fiddle
您可以使用 RegExp 将不需要的字符串替换为空字符串:
此正则表达式查找
hello/
的任何实例(不区分大小写)并将其替换为空字符串。这是一个演示: http://jsfiddle.net/K8xMf/
You can use RegExp to replace the unwanted string(s) with a blank string:
This regular expression looks for any instance of
hello/
(case-insensitive) and replaces it with a empty string.Here is a demo: http://jsfiddle.net/K8xMf/