请提供验证码 [英] pleae provide validations code
问题描述
大家好,
请为我建议以下条件的验证码
1.Password必须至少有八(8)个字符。
2.密码必须至少有四(4)个字符类型中的三(3)个:小写字母,大写字母,数字和特殊字符。
3.Password不得与用户标识符相同。
4.密码不得包含三(3)个或更多重复字符。
谢谢
Rajshree lande
hello guys,
please suggest me validation code for following conditions
1.Password must have a minimum of eight (8) characters.
2. Password must have at least three (3) of the four (4) character types: lowercase alphabetic, uppercase alphabetic,numeric, and special characters.
3.Password must not be the same as the user identifier.
4. Password must not contain three (3) or more repeating characters.
thanks
Rajshree lande
推荐答案
此类验证代码的实现非常简单(因此请考虑自己动手并在此处仅询问具体问题)。例如,假设用户输入的(string
)变量为pwd
,您可以检查点(1)使用以下代码:
Implementation of such validation code is pretty trivial (so consider doing it yourself and ask here only specific questions). For instance, suppose the (string
) variable entered by the user ispwd
, the you may check point (1) using the following code:
if (pwd.Lenght < 8)
{
return false;
}
其他要点稍微复杂一些。
Other points are just a little bit more complex.
^(?=.*[A-Z])(?=.*\d)(?!.*(.)\1\1)[a-zA-Z0-9@]{6,12}
特殊字符 - 不允许
空格 - 不允许>
最小和最大字段长度 - 6到12个字符
遇到[a-zA-Z0-9 @] {6,12}
数字角色 - 至少一个角色
遇到积极前瞻(?=。* \ d)
至少一封大写字母
遇见积极前瞻(?=。* [AZ])
重复字符 - 仅允许两个重复字符
我不确定你的意思。否定前瞻(?!。*(。)\\\ 1)确保不允许任何字符连续出现两次以上。子串aa没关系,aaa不行。
制作它(?!。*(。+)\\\ 1)拒绝长度不止一个的重复子串(如ababab)或添加。*在\1之前拒绝不连续的重复出现。
参考: http://stackoverflow.com/questions/12899876/checking-strings-for-a-strong-enough-password [ ^ ]
或
Special Characters - Not Allowed
Spaces - Not Allowed
Minimum and Maximum Length of field - 6 to 12 Characters
Met by [a-zA-Z0-9@]{6,12}
Numeric Character - At least one character
Met by positive lookahead (?=.*\d)
At least one Capital Letter
Met by positive lookahead (?=.*[A-Z])
Repetitive Characters - Allowed only two repetitive characters
I am not sure what you mean by this. The negative lookahead (?!.*(.)\1\1) makes sure that no character is allowed to appear more than two times in a row. Substring aa is okay, aaa is not.
Make it (?!.*(.+)\1\1) to reject repeated substrings of length more than one (like ababab) or add .* before \1 to reject non-continuous repeated appearances too.
refer: http://stackoverflow.com/questions/12899876/checking-strings-for-a-strong-enough-password[^]
OR
You can do these checks using positive look ahead assertions:
<pre lang="xml">^(?=.*[A-Z].*[A-Z])(?=.*[!@#
这篇关于请提供验证码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!