0

i've got something that i wanted to do , and how do i automatically update the age of the person when he choose the calendar. And later i wanted to save it to my DB.

I'm currently using JSF Primefaces.

<p:outputLabel value="born date" style="font-weight: bold; "/>
<p:calendar value="#{form.person.bornDate}" 
pattern="dd-MM-yyyy" navigator="true" maxdate="now()"
showOn="both" effect="slideDown" yearRange="c-100:c+0"
readonlyInput="true" style="width: 100%;" disabled="true"
required="true" requiredMessage="born date can't be null!" >
</p:calendar>
<p:outputLabel value="Age" style="font-weight: bold; "/>
<p:inputText value="33" id="age"
maxlength="3" style="text-transform: uppercase; width: 100%;"
disabled="true"/>

So if user change the calendar component to become 11/03/1990 it will become 31, and if he changes it to become 11/03/1991 the age will become 30.

Jasper de Vries
  • 13,693
  • 6
  • 54
  • 86

0 Answers0