输入2个字符后,文本框中需要一个空格. [英] Need a Single Space in Textbox after entering 2 characters.
问题描述
亲爱的朋友们,大家早上好.
正在使用Asp.net,C#,SqlServer2005.
我的要求是我有一个文本框可以从Gridview中搜索数据...工作正常.
现在我需要在文本框中输入2个字母后在文本框中添加空间.
例如,我需要像这样进行搜索.....
MS 651
在258
XY 701
IY 532
我需要像MS 651这样的两个字符后面有一个空格...以便我可以轻松地搜索数据.
用于显示大写字母,我给文本框css为
text-transform:uppercase;
工作正常.
但是我在TEXTBOX中输入两个字符后需要一个空格.
请帮帮我,
谢谢.
Dear Friends, a very good morning to everyone.
am working on Asp.net,C#,SqlServer 2005.
My Requirement is I have a Textbox to Search the data from Gridview...its working fine.
now I need to add space in Textbox after entering 2 letters in Textbox.
for example I need to Search like this.....
MS 651
AT 258
XY 701
IY 532
I need a single Space after two characters like this MS 651...so that I can Search the data easily.
for displaying capital letters i gave textbox css as
text-transform:uppercase;
its working fine.
But I need a single space after two characters entered in TEXTBOX.
Please help me,
THANKS.
推荐答案
使用字段验证器并编写正则表达式(regex)来解决您的问题.
这是.net的正则表达式类的链接
http://msdn.microsoft.com/en-us/library/system. text.regularexpressions.regex.aspx [ ^ ]
和你的孩子会是这样的
字符串模式= @"[[A-Za-z] [A-Za-z] \ s [0-9] {6}";
[] =此集合中出现了一次
\ s =空白
{X} =总长度为X(如果空格后的数字可以变化,请不要使用该数字).
use a field validator and write a regular expression (regex) to solve your problem.
here is link for regex class of .net
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^]
and your patren would be something like this
string pattern = @"[A-Za-z][A-Za-z]\s[0-9]{6}";
[]=single occurrence from this set
\s= white space
{X}=total length is X (dont use this if the digits after space can vary).
这篇关于输入2个字符后,文本框中需要一个空格.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!