Search code examples
c#javascriptdevexpressclient-side-validation

ASPxTextBox ErrorText Not Updated on Lost Focus


I got this ASPxTextBox:

<dxe:ASPxTextBox ID="txtFirstName" runat="server">
    <ClientSideEvents LostFocus="function(s, e) {
        if (s.GetText() == '')
        {
            s.SetIsValid(false);
            s.errorText = 'Please enter First Name.';
        }
    }"></ClientSideEvents>
    <ValidationSettings ErrorDisplayMode="ImageWithTooltip">
    </ValidationSettings>
</dxe:ASPxTextBox>

But the errorText displayed isn't what I have set inside the LostFocus event. Instead, the default errorText which is "Invalid value" is displayed in the tool tip.

Any ideas? Thanks


Solution

  • I happen to solve the problem:

            if (s.GetText() == '')
            {
                s.errorText = 'Please enter First Name.';
                s.SetIsValid(false);
            }
    

    Modifying the value of errorText should come first before setting IsValid property of the ASPxTextBox to false.

    (I want to laugh at my stupidness! OMG)

    Thanks for those who helped. :)