Ticket T649960
Visible to All Users

ASPxTextBox - How to implement custom validation and change error text based on a certain condition

created 7 years ago

How show/activate the dx:ASPxTextBox ValidationSettings ErrorText frome Code Behind?

I use dx:ASPxTextBox to check if email exist before input and i want to show the ErrorText frome Code Behind and different ErrorText if  Email address already exists

This work fine: tbEmail.BackColor = Color.LightYellow

ASPx
<dx:ASPxTextBox ID="tbEmail" MaxLength="50" Width="240px" Caption=" " EnableClientSideAPI="True" ClientInstanceName="Email" NullText="E-mail" HelpText="E-mail" HelpTextSettings-DisplayMode="Popup" ValidationSettings-ErrorTextPosition="Right" runat="server"> <ValidationSettings ErrorDisplayMode="ImageWithText" Display="Dynamic" ErrorFrameStyle-ImageSpacing="0"> <ErrorImage Url="../images/thumb/varning_red.png" /> <RegularExpression ErrorText="Incorrect email address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" /> <RequiredField IsRequired="True" ErrorText="E-mail is required" /> </ValidationSettings> <InvalidStyle BackColor="LightYellow" /> <CaptionSettings Position="right" /> </dx:ASPxTextBox>

Answers approved by DevExpress Support

created 7 years ago

Hello,

You can implement custom validation using the approach described in the How to: Implement a Custom Validation article. To display custom error text, use the client-side ASPxClientTextBox.SetErrorText method.
Let us know if you have any further questions.

Best regards,
Stanley

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.