-3

I am developing one form in jsf/primefaces. I have two inputText(inputMask) for e.g moble number and telephone number. I want to restrict the user to put only one of these two fields . That means if user starts putting value in mobile no. then telephone no. field should be disabled and if user starts putting value in telephone no. then mobile no. field should be disabled.

Please tell me how should I do this.

user247702
  • 23,641
  • 15
  • 110
  • 157
Dhiraj_N
  • 51
  • 1
  • 2
  • 8
  • I think you can use this: http://stackoverflow.com/questions/19537358/disable-opposite-input-if-i-type-into-another-of-a-pair – Jaqen H'ghar Jul 28 '14 at 09:15
  • Thanks for ur reply . But I tried in different way and it's working as per my requirement now. I used onkeyup=someFunction(idOfInputText,idToBeDisabled) in inputText and in someFunction I used conditions. – Dhiraj_N Jul 28 '14 at 09:54

1 Answers1

0

See in the primefaces docs or showcase: http://www.primefaces.org/showcase/ui/ajax/event.xhtml

<p:inputText id="mobil" value="#{bean.mobil}" disabled="#{bean.isMobilDisabled}">
   <p:ajax event="blur" update="tel" />
</p:inputText>

<p:inputText id="tel" value="#{bean.tel}" disabled="#{bean.isTelDisabled}">
   <p:ajax event="blur" update="mobil" />
</p:inputText>

In the bean check if the other one is sets, valid, etc. and return a boolean to the disabled attribute.

user3608395
  • 1
  • 1
  • 3