0

i need a code in asp validationExpression to vallidate an expression that can eneable us to Avoid the submit if ther is any lettre (d) in the end of the Word

exemples :

disable : GIAC1-IMME-D (BAD)

eneable : GIAC1-IMME (GOOD)

put it here :

     <asp:RegularExpressionValidator ID="RegularExpressionValidator5"  runat="server" ControlToValidate="date_Fin" 
Display="Dynamic" ErrorMessage="Invalid date"
 ForeColor="Red" ValidationExpression=""></asp:RegularExpressionValidator>

tnks my clan 
Yassine edouiri
  • 281
  • 3
  • 14
  • 30

2 Answers2

1

I'm assuming you are talking about the ValidationExpression attribute of the RegularExpressionValidator control. If that is the case you can use the regex below. It will match any string that contains anything except a newline character and doesn't end in a lower or uppercase d.

^.*[^Dd]$
ryanulit
  • 4,983
  • 6
  • 42
  • 66
  • this is it tnks my friend ... i have an another probléme i want to use it in a CreateUserWizard it doesn't work – Yassine edouiri Jul 20 '12 at 14:57
  • 1
    The CreateUserWizard issue could be just a matter of making sure your ValidationGroup attributes have the same value everywhere. These two SO links seem to address that issue: http://stackoverflow.com/questions/5955280/server-side-validation-for-createuserwizard and http://stackoverflow.com/questions/3923492/regular-expression-validation-control-stops-working-when-embedded-in-a-createuse – ryanulit Jul 20 '12 at 15:04
  • tnks dudde .. that's it so all what i need it to write the validation groupe i use it and it works as well tnksssssss – Yassine edouiri Jul 20 '12 at 15:20
0

CascadeMode = CascadeMode.StopOnFirstFailure;

RuleFor(x => x.Field).Trim().ToUpper() .EndsWith("D") .WithMessage("No Ds please");

dreamerkumar
  • 1,540
  • 1
  • 18
  • 28