[CLOSED] RemoteValidation not firing when text is not changed

  1. #1

    [CLOSED] RemoteValidation not firing when text is not changed

    Hi.

    I have a form that loads information in a multilanguage scenario.

    Let's say we are managing Countries with their translations.

    There are two classes:

    Country {Id, ISO}
    ConutryTr{Id, Country_Id, Language_Id, Name}

    The form has at least a TextField for ISO, another for Name and a Combo with languages.

    By default the combo selects one languaje, let's say English.

    The ISO text is filled once as it is not translated.

    The textbox for Name is filled with the information in that language, let's say: Germany

    The form mandatory needs to be filled in all languajes.

    I change the combo and select other language, lest's say, Spanish.

    There, a DirectEvent is fired, and serverside I perform this operations:

    Get last selected language (english)
    Assign to English translation the text Germany
    Blanks Name text
    Shows new selected languaje in combo (Spanish).

    Every time I change Language, this operation happens without problem.

    The problem comes with the Text Field Remote validation.

    Every time the textbox changes it fires a remote validation that validates not only the "not empty" status of the textbox itself, but that all translations are filled serverside.

    If I add a new Country, I enter the first Country name in English. Let's say: 'Colombia'

    Then select the new language (Spanish), so "Colombia" is assigned to English translation of the Country.

    The Textbox for name is cleared and also its validation (so, no validation error is shown until a new remote validation).

    When I enter the new translated name for the country it must be different. In the case of Colombia, both for English and Spanish spells the same, so if I type once "Colombia" the Remote validation is not fired. It seems like the control remembers the last text before clear().

    If I type slowly and partially the name, "Col"... wait ... "ombia" then the RemoteValidation fires twice and everything runs fine.

    Is there anyway to force Remotevalidation it doesn matter the text doesn't change?

    I can't paste the whole code cause it calls some clases and methods and the post will get too long, but here are the essentials:

    Name textbox:
    <ext:TextField ID="txtNombre" runat="server" Width="250" FieldLabel="Nombre"
                                    MaxLength="200" MsgTarget="Side" IsRemoteValidation="true">
                                    <RemoteValidation OnValidation="VerificarTraduccionesNombre" Timeout="2147483647">
                                    </RemoteValidation>
                                    </ext:TextField>
    Validation handler
    Protected Sub VerificarTraduccionesNombre(ByVal sender As Object, ByVal e As Ext.Net.RemoteValidationEventArgs)
    
    
            txtNombre.ClearInvalid()
    
    
            Dim mPais As Pais = EntidadObtener("Pais")
    
    
            Dim mValido As Boolean = True
            Dim mIdiomasIncompletos As String = ""
            Dim mCantidadIdiomas As Integer = 0
    
    
            For Each mTr As PaisTr In mPais.Traducciones  'Traducciones = Translations. Type= List(Of PaisTr)
    
    
                If mTr.Idioma <> cmbIdiomas.SelectedItem.Value AndAlso mTr.Nombre = "" Then 'Checks for every Translation to be filled but the new selected one (which is expected to be filled now)
                    mValido = False
                    If mCantidadIdiomas = 0 Then
                        mIdiomasIncompletos = (New Idioma(mTr.Idioma)).Nombre
                    Else
                        mIdiomasIncompletos &= ", " & (New Idioma(mTr.Idioma)).Nombre
                    End If
                    mCantidadIdiomas += 1
                End If
            Next
    
    
            If Not mValido Then
                e.Success = False
                If mCantidadIdiomas = 1 Then
                    e.ErrorMessage = "Falta especificar la traducción para el idioma " & mIdiomasIncompletos
                Else
                    e.ErrorMessage = "Falta especificar la traducción para los siguientes idiomas: " & mIdiomasIncompletos
                End If
            Else
                e.Success = True
            End If
    
    
        End Sub
    Sorry for the spanish and VB.NET (I don't know which one of them dislikes you more) ;-)

    Thanks
    Regards
    Fernando
    Last edited by Daniil; May 11, 2012 at 4:37 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Thanks for the such detailed description.

    Please set up:
    <Listeners>
        <Render Handler="this.performRemoteValidation = this.performRemoteValidation.createInterceptor(function () {
                             delete this.rvConfig.lastValue;
                         });" />
    </Listeners>
    for the TextField.

    P.S. Spain is great. It gave the World so many wonderful football teams :) VB.NET is not so great :)))
  3. #3
    Wow, what a complicated solution. It worked great. Thanks a lot.
    It would be nice to include this like a boolean attribute or something in 2.0.

    Something like:

    <ext:TextField ID="txtNombre" runat="server" Width="250" FieldLabel="Nombre" MaxLength="200" MsgTarget="Side" IsRemoteValidation="true">
                                    <RemoteValidation OnValidation="VerificarTraduccionesNombre" CacheLastValue="false" >
                                    </RemoteValidation>
                                    </ext:TextField>
    You may close this.
    Regards
    Lionel Messi
  4. #4
    Thanks for the suggestion. We will consider.

    Though I have found a simpler solution.

    Example
    <ext:TextField runat="server" IsRemoteValidation="true">
        <RemoteValidation 
            OnValidation="RemoteValidation" 
            After="delete this.control.rvConfig.lastValue;" />
    </ext:TextField>
    Quote Originally Posted by FAS View Post
    Regards
    Lionel Messi
    Nice to meet you, Lionel:)

Similar Threads

  1. Text field event changed or leave
    By naina in forum 1.x Help
    Replies: 1
    Last Post: Aug 19, 2011, 12:24 PM
  2. Replies: 6
    Last Post: Aug 01, 2011, 4:53 PM
  3. RemoteValidation help (not firing on second blur)
    By Tallmaris in forum 1.x Help
    Replies: 5
    Last Post: Jul 07, 2011, 12:06 PM
  4. [CLOSED] [1.0] RemoteValidation
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 25
    Last Post: Dec 25, 2010, 1:07 PM
  5. Firing keyups for text box
    By ranganath in forum 1.x Help
    Replies: 3
    Last Post: May 18, 2009, 2:04 AM

Tags for this Thread

Posting Permissions