nopCommerce:SimpleTextBox with asp:RegularExpressionValidator

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
Hi,
I try to implement a RegularExpressionValidator on the Postal code and Phone number field in the AddressEdit.ascx page.
I added RegularExpressionValidator to Customerinfo.ascx page and other pages that contain the Postal code number and / or Phone number and it works.

However in the AddressEdit.ascx page, the phone number and Postal code are defined with nopCommerce:SimpleTextBox.
Why this specific type and why it dosen't herit propreties from the asp:textbox class.
Wich is the best solution to add my validator ?

Thank you .
13 年 前
Here is my solution.
I changer the type of those fields ;)


<asp:TextBox runat="server" ID="txtZipPostalCode"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvZipPostalCode" runat="server" ControlToValidate="txtZipPostalCode"
            ErrorMessage="<% $NopResources:Account.ZipPostalCodeIsRequired %>" ToolTip="<% $NopResources:Account.ZipPostalCodeIsRequired %>"
ValidationGroup="CustomerInfo">*</asp:RequiredFieldValidator>
                                    
<asp:RegularExpressionValidator runat="server"      id="regexptxtZipPostalCode" ControlToValidate="txtZipPostalCode"      
ValidationExpression="^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])\ {0,1}(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$"      ErrorMessage = "<% $NopResources:Axial.Message.InvalidPostalCode %>"   Display="Dynamic" />
13 年 前
I have just been having a similar problem with a NumericTextBox.

I added some functionality to my page for TextChanged event and I ended up replacing the NumericTextBox with an ASP:textBox, required and range validation controls on the page.

Then I could test for the validation in my TextChanged event so that the error messages still showed and the funcrtionality in the TextChanged event would only run if both were valid.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.