开发者

RegularExpressionValidator in codebehind (web services)

开发者 https://www.devze.com 2023-02-14 15:53 出处:网络
i am working with web services webmethod and i have a method that accepts a string of phonumber (1234567890) and how can i make sure before i make a call to API that, the phone number is valid 开发者_

i am working with web services webmethod and i have a method that accepts a string of phonumber (1234567890) and how can i make sure before i make a call to API that, the phone number is valid 开发者_Go百科(no characters or not less then 10 digits)

how can i implement in web.service?


You would implement the RegularExpressionValidator on the UI. If the text doesn't meet the regular expression pattern, the validator IsValid will be False. The page shouldn't execute any code until the phone number field meets your regular expression pattern.

Before calling your web service, check if Page.IsValid, too.


To validate a string that consists only of digits and is at least 10 digits long, use this (server- or client-side):

^\d{10,}$

Explanation:

^        # Anchor the regex at the start of the string.
\d{10,}  # Match 10 or more digits until the...
$        # end of the string.
0

精彩评论

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