10 Replies Latest reply on Mar 14, 2009 9:15 AM by Franco Fernandes

    Richfaces event with JQuery masked input

    Franco Fernandes Novice

      Sorry to post here, not sure if I could get any help from a jQuery forum because of the nature of the problem.

      I know some RF users have been using different jQuery plugins for masked inputs. I am using this one http://www.meiocodigo.com/projects/meiomask/
      and I highly recommend it.

      It works great on any input ONLY where there is no attached a4j events.

      Let me explain with my code-

      <!-- Set up mask -->
      <script type="text/javascript" src="#{contextPath}/js/jquery/plugins/jquery.meiomask.compressed.js" ></script>
      <script type="text/javascript">
       // Use jQuery via jQuery(...)
       //use meiomask to set input masks
       jQuery.mask.masks = jQuery.extend(jQuery.mask.masks,{
       msrpmask:{ mask: '99.999999', type : 'reverse'},
       lsppgmask:{ mask: '99.999999', type : 'reverse'},
       inventorymask:{ mask: '999999', type : 'reverse'}
       //then call this to activate masks lib

      Now here is the definition of my masked input in my xhtml page
      <s:decorate id="msrpDecoration" >
      <h:inputText id="msrp" value="#{itemHome.instance.msrp}"
       alt="msrpmask" >
       <a4j:support event="onblur"

      I need the a4j:support event to match a validation on my model that will not allow a zero value in this field.

      Here is the behavior I am experiencing

      Page loads the first time, the mask works great, only decimal numbers are allowed. However, once I tab out of the field and go back in, the mask is lost. I can now type anything. If I remove the a4j event, then the mask always works.

      I am hoping someone here is also using a masked input and knows something I am missing here. Or perhaps some tips from RF team.

      Regards and thanks in advance