检查有效输入 [英] check for valid input
本文介绍了检查有效输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我说,如果我的输入分为4种类型,则应该有一个按钮来检查每个输入的有效性.
Let say , if my input is grouped into 4 types and there should be a button to check the valid of each input.
How am i goin to code the button to check for the valid of my input?
推荐答案
如果使用的是ASP.NET,则可以使用可用的验证控件来检查输入内容是否有效.如果每个字段都是必需的(RequiredFieldValidator),满足特定表达式(RegularExpressionValidator),是否在特定范围内(RangeValidator),或者您可以比较字段(CompareValidator)甚至在客户端或服务器端编写自己的验证器(CustomValidator).
默认情况下,您的按钮为CausesValidation ="true",并且您可以根据需要设置ValidationGroup.与按钮相同的ValidationGroup中的每个字段都将进行相应的验证.
If you are using ASP.NET you could use the validation controls available to check if each field is required (RequiredFieldValidator), meets a specific expression (RegularExpressionValidator), is in a specific range (RangeValidator) or not or you can compare fields (CompareValidator) or even write your own validator (CustomValidator) in client or server side.
Your button is by default CausesValidation="true" and you can set a ValidationGroup if need be. Each field in the same ValidationGroup as your button will be validated accordingly.
您好,
最简单的方法是使用正则表达式来检查输入的字符串是否有效.表达式((?=.*\\d)(?=.*[A-Za-z])(?=.*[@#
Hi,
The easiest way is to use a regular expression to check if the entered string is valid. The expression((?=.*\\d)(?=.*[A-Za-z])(?=.*[@#
%]))将检查输入的字符串是否包含至少1个数字(?=.*\\d)
,1个字母(大写或小写(?=.*[A-Za-z])
和列表(?=.* [@#
%])) will check if the entered string contains at least 1 number(?=.*\\d)
, 1 letter(either upper or lower case(?=.*[A-Za-z])
and 1 character in the list(?=.*[@#
这篇关于检查有效输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文