1
I have the following field and validator in ASP.NET Webform
<asp:TextBox ID="txt_Senha" runat="server" CssClass="form-control" placeholder="Senha" TextMode="Password" AutoCompleteType="Disabled"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txt_Senha" ValidationExpression="(?=.{8,})[a-zA-Z]+[^a-zA-Z]+|[^a-zA-Z]+[a-zA-Z]+" ErrorMessage="A senha deve conter:<BR> * Mínimo 8 dígitos;<BR>* Números;<BR>* Letras MAIUSCULAS e minusculas" ForeColor="Red" />
When testing regular expression in: http://ferramentas.lymas.com.br/regexp/regexp_br.php
Works well, but on the page it does not accept the password:
1q2w3e4f5t6y7u8i
I believe it’s because there’s no Maluscula? But accept the password:
quadros2014
and quadros2014a
unaccepted
Just to add, I’d do it this way
(?=.{8,})([a-zA-Z0-9]+)
, add parentheses to catch the group.– MeuChapeu
I didn’t remember either
(?i)
when I did my answer, summarizing the string to(?i)(?=.{8,})([a-z0-9]+)
– Guilherme Lautert
I liked your answer
+1
. I think the AP wants to force at least one of each type, in their response cases without uppercase pass. Let’s see what he really wants when he responds/gives feedback.– Sergio
Thank you all, really needed minimum 8 characters, a minuscule, a capital case, a number and that accepts special characters but is not mandatory.
– Dorathoto
@Dorathoto, because of your needs, I believe the correct answer is Sergio’s. Mine makes the validation correct but does not contemplate the need for a character of each type. = D
– Guilherme Lautert