I have a regular expression validator in an ASP.Net Webforms app that makes sure the input in a textbox is a combination of these characters alphabets, digits, period, hyphen and single quote as in code below. Since this ASP.Net is multi-lingual i.e. both English and non-English cultures are allowed, the regex validator will need to b disabled when its being accessed from a non-English culture.
Question
Is the code-behind mentioned below going to satisfy this requirement of disabling the regex validator when being accessed from a non-English culture, Or is the code lacking something?
Regex Validator
<asp:RegularExpressionValidator
ID="revProdName" runat="server"
ErrorMessage="RegularExpressionValidator" ControlToValidate="ctxtProductName"
ValidationExpression="^[(a-z)(A-Z) .'-(0-9)]+$"></asp:RegularExpressionValidator>
Code-behind of page
If System.Globalization.CultureInfo.CurrentUICulture.DisplayName.StartsWith("en-") Then
revProdName.Enabled = True
Else
revProdName.Enabled = False
End If
Aucun commentaire:
Enregistrer un commentaire