3 Replies Latest reply on May 9, 2011 8:21 AM by ilya_shaikovsky

    validate h:textInput only if any value is entered

    nikh123123

      Hey guys,

       

      I'm trying to add regex validation to an optional field

       

       

      <h:inputText
                  id="txtContact" 
                  value="#{user.contact}"
                  required="false"
                  validatorMessage="Invalid phone number"
                  maxlength="10">
                    <f:validateRegex pattern="\d{10}" />
                    <rich:validator/>
      </h:inputText>
      
      

      This valides the text field even if its kept empty. I want it to be validated only if user enters something. How to achieve this?