验证文本框以允许用户定义字符 [英] validating text box to allow user define charactor

查看:99
本文介绍了验证文本框以允许用户定义字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要验证文本框,其中前两个字符允许使用字符串"ES",然后允许使用int值(例如123456).

我想要这样:-ES45612或es45612

I want to validate text box that first two charactor allow string ''ES'' and after that it allow int value such as 123456.

I want like this:-ES45612 or es45612

推荐答案

您可以尝试遵循正则表达式.

You can try following regex.

string myCheck = "^[E][S]\\w*";
string myStr = "ES12121";
if(Regex.IsMatch(myStr,myCheck,RegexOptions.IgnoreCase))
{
    Console.WriteLine("Yes, it starts with ES");
}
else
{
    Console.WriteLine("No Its not!!");
}
Console.ReadKey();



希望能有所帮助.如果有帮助,请将答案标记为解决方案.

谢谢
Milind



Hope that helps. If it helps, mark the answer as solution.

Thanks
Milind


使用正则表达式验证器.
访问以下链接以获取更多详细信息:
http://msdn.microsoft.com/en-us/library/ms972966.aspx [ ^ ]
http://www.w3schools.com/aspnet/control_regularexpvalidator.asp [ http://msdn.microsoft.com/en-us/library/ff650303.aspx [ ^ ]
Use Regular Expression Validator.
Visit folowing links for more details:
http://msdn.microsoft.com/en-us/library/ms972966.aspx[^]
http://www.w3schools.com/aspnet/control_regularexpvalidator.asp[^]
http://msdn.microsoft.com/en-us/library/ff650303.aspx[^]


这篇关于验证文本框以允许用户定义字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆