2

I tried to define an xhtml time field in hours and minutes with "HHH:mm" format thanks to the following inputMask.

<p:inputMask id="time"
             value="#{task.time}"
             converter="#{myBean.timeConverter}"
             size="8"
             mask="999:99">
</p:inputMask>

The problem is if I put 012 and press "Enter" or unfocus the field, it is cleared and I don't know how to manage it. Moreover I would like to complete automatically the field with "0" in that case : getting 012:00 if i put 012 or 240:00 if I put 24, etc.

fuggerjaki61
  • 822
  • 1
  • 11
  • 24
  • Maybe this helps you [JSF Regex validation](https://stackoverflow.com/questions/19161040/how-to-validate-string-input-field-for-pattern-on-jsf-form). If adding zeros isn't relevant on server-side, I would do it in js. – fuggerjaki61 Aug 27 '20 at 13:06

1 Answers1

4

The property you want is autoClear='false'.

See the docs: https://primefaces.github.io/primefaces/8_0/#/components/inputmask?id=attributes

autoClear - Clears the field on blur when incomplete input is entered.

That will stop it from clearing the field. As for finishing the mask you will have to do that yourself with onblur Javascript.

Melloware
  • 10,435
  • 2
  • 32
  • 62