如何使验证为只接受逗号(,)及一个文本框;位在ASP.NET应用程序? [英] How to make validation for a textbox that accepts only comma(,) & digit in an ASP.NET application?

查看:114
本文介绍了如何使验证为只接受逗号(,)及一个文本框;位在ASP.NET应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作在网站上。我使用相应的Visual Studio 2008中我要特别强调只接受数字放大器和一个文本框,C#;逗号(,)。
例如,

I am working on a website. I am using C# corresponding to Visual Studio 2008. I want to make a text box that accept only numbers & comma(,). For example,

-919981424199,78848817711,47171111747 

或有可能像单号 919981424199

我能够做的一件事。我的文本框只能使用此正前pression验证包含数字。在其财产而>验证前pression我写了[0-9] +。
这是工作,但现在我的要求是发送群发短信,而且每个数由(,)隔开。
我尝试了很多,但我没有得到答案。这是什么?

I was able to do one thing. My text box is only containing a number by using this regular expression validation. In its property->Validation Expression I wrote "[0-9]+". This is working, but now my requirement is to send bulk SMS, and each number is separated by (,). I tried a lot, but I am not getting the answer. What is it?

推荐答案

只需添加,到你的正常的前pression。从内存中,我认为它应该是:

Just add "," to your regular expression. From memory I think it should be:

"[0-9]+(,[0-9]+)*"

来源

要打破输入号码列表使用 String.Split() 用逗号作为分隔符:

To break the input into a list of numbers use String.Split() with the comma as the delimiter:

string[] numbers = string.split(input, ",");

然后遍历所有的数字阵列发送您的短信到每个

Then loop over the numbers array sending your SMS to each.

这篇关于如何使验证为只接受逗号(,)及一个文本框;位在ASP.NET应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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