2 Replies Latest reply on Jun 20, 2012 9:10 AM by David Maple

    Are there javascript event hooks for client side validation?

    David Maple Newbie

      I've been using rich:validator to handle our client validation for a while now. It works like a champ. I have some new requirements for a different display on errors that requires me to alter some other presentation elements (other than just rich:message). I was hoping there was an attribute or some way to perform another javascript function once client validation finishes. Something like:

       

      <h:inputText value="#{bean.property}">

           <rich:validator oncomplete="myCustomFunction()" />

      </h:inputText>

       

      Naturally I've tried oncomplete and onbeforedomupdate, neither of which seem to work. It there a way to hook into the client event model?

       

      Edit: Richfaces 4.0.0.Final is the version I'm using. I tried updating to 4.2.2 but still didn't find these events to be working.

        • 1. Re: Are there javascript event hooks for client side validation?
          Siva P Master

          You can use h:message

            OR

          h:outputtext text diaplay with the "rendered" attribute  set some value in Backend and display the text and change the color to red using style tag.

          OR

          You can use Jquery for validation for javascript.So for that you have to integrate it with Richfaces.

          • 2. Re: Are there javascript event hooks for client side validation?
            David Maple Newbie

            I'm not following you. I'm not having an issue getting text to display that turns red. That is easily accomplished by using rich:message:

             

            <h:inputText value="#{bean.property}" id="textField">

                 <rich:validator oncomplete="myCustomFunction()" />

            </h:inputText>

            <rich:message for="textField" />

             

            Server side doesn't help me because I'm looking to achieve everything client side (thus rich:validator). I also don't want to write custom jquery validations -- the whole beauty of rich:validator is that you can define bean validations once and enjoy them at all levels -- all the way to the client's browser. But what I do need is a way to hook into the event model in the CSV classes to expand the presentation of errors to include a div that wraps multiple fields. This can be accomplished if there is a way to define "myCustomFunction()" to be executed after the CSV routine.

             

            Thanks for any help.