开发者

How to make validation for a textbox that accepts only comma(,) & digit in an ASP.NET application?

开发者 https://www.devze.com 2022-12-31 12:20 出处:网络
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(,).

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 

or there may be a single number like 919981424199.

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 wor开发者_开发问答king, 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?


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

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

Source

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号