Antoine Banck
Antoine Banck

Reputation: 55

inputMask automatic completion by loosing focus

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.

Upvotes: 2

Views: 992

Answers (1)

Melloware
Melloware

Reputation: 12029

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.

Upvotes: 4

Related Questions