5 Replies Latest reply on Feb 22, 2010 6:41 AM by ilya_shaikovsky

    double email field validation

    hferreira25

      Hi,

       

      I have two email inputText fields (email and confirmationEmail).

       

      Now I need to confirm if both correspond to email and if both are equal. And I would like to do this in a AJAX way.

       

      This means, I dont want to perform validation only when the user press the submit button, but imediatlly after the user

      enter the confirmationEmail field.

       

      The problem is that the tests that I've made the fields are only set in the bean when the user press submit.

       

      How can I do that?

       

      Thanks for the help

        • 1. Re: double email field validation
          ilya_shaikovsky
          you could add validation to second field using ajaxValidator component. please show code you tried ifnot helps.
          • 2. Re: double email field validation
            hferreira25

            Not getting how to do-it

             

            I've the following code

             

            <h:panelGrid columns="2">
                <h:outputText value="Attr1"/>
                <h:panelGroup>
                    <h:inputText value="#{bean.a1}" id="a1ID" required="true"
                                 requiredMessage="Please fill" validatorMessage="Not correctly filled">
                        <!--f:validator validatorId="EmailValidator" /-->
                        <f:validateLength for="a1ID" maximum="5" minimum="2" />
                        <a4j:support ajaxSingle="true" event="onblur" process="a2ID"/>
                    </h:inputText>
                    <rich:message for="a1ID"/>
                </h:panelGroup>
                <h:outputText value="Attr2"/>
               <h:panelGroup>
                    <h:inputText value="#{bean.a2}" id="a2ID" required="true"
                                 requiredMessage="Please fill" validatorMessage="Not correctly filled"
                                 >
                        <!--f:validator validatorId="EmailValidator" /-->
                        <f:validateLength for="a2ID" maximum="5" minimum="2" />
                        <a4j:support ajaxSingle="true" event="onblur" process="a1ID"/>
                    </h:inputText>
                    <rich:message for="a2ID"/>
                </h:panelGroup>
                <a4j:commandButton action="toPage6" value="NextPage"/>
            </h:panelGrid>

             

            Event I if replace the a4j:support with rich:ajaxValidator each field is validated alone without any interaction between the two. Event more, I can not do the validation in the Bean since the two field are null, they are only setted after I press the commandButton

            • 3. Re: double email field validation
              ilya_shaikovsky
              • 4. Re: double email field validation
                hferreira25

                Thanks a lot for your help, this works ok

                • 5. Re: double email field validation
                  ilya_shaikovsky

                  good to hear.

                   

                  B.t.w. moving thread to RichFaces space from RichFaces development.