简体   繁体   English

使用ASP.NET的正则表达式

[英]Regular Expression using ASP.NET

I would like to know about regular expression and text validators using ASP.NET. 我想了解使用ASP.NET的正则表达式和文本验证器。 Do the tags used to control the inputs only check data client side, or is the data also checked server side? 用于控制输入的标签仅检查数据客户端,还是检查服务器数据?

You might want to check this out 您可能要检查一下

http://msdn.microsoft.com/en-us/library/ms972966.aspx http://msdn.microsoft.com/en-us/library/ms972966.aspx

It is said : 据说 :

"A few things to note about the RegularExpressionValidator: “有关RegularExpressionValidator的几点注意事项:

  • It will never be activated by an empty string in the control it is validating. 它永远不会被正在验证的控件中的空字符串激活。 Only the RequiredFieldValidator catches empty strings 只有RequiredFieldValidator捕获空字符串
  • You do not need to specify beginning of string and end of string matching characters (^ and $)—they are assumed. 您无需指定字符串的开头和字符串末尾的匹配字符(^和$),它们都是假定的。 If you add them, it won't hurt (or change) anything—it's simply unnecessary. 如果添加它们,它不会伤害(或更改)任何内容-根本没有必要。
  • As with all validation controls, the validation is done client-side as well as server side. 与所有验证控件一样, 验证是在客户端和服务器端进行的。 If your regular expression is not ECMAScript compliant, it will fail on the client. 如果您的正则表达式不符合ECMAScript,则它将在客户端上失败。 To avoid this, either ensure your expression is ECMAScript compliant, or set the control to perform its validation only on the server." 为避免这种情况,请确保您的表达式符合ECMAScript,或者将控件设置为仅在服务器上执行其验证。”

The validation controls validate on both the client and the server . 验证控件在客户端服务器进行验证。 Please learn to google your questions prior to asking for help - you'll become a better softare developer for it. 在寻求帮助之前,请先学习Google的问题-您将成为更好的软件开发商。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM