title: calculate age javascript in adobe acrobat
body: <p>I am having some difficulties getting a field to populate in an interactive PDF form. I am using a javascript to calculate the current age of client from 2 date fields (DateToday and ClientDOB) already in the form and I need it to populate a "ClientAge" field. The DateToday field automatically populates when the form is opened. I would like for the ClientAge field to populate after the user selects the ClientDOB.</p>
  
  <p>This is what I am trying to have it do. Should be simple I would think. </p>
  
  <p>DateToday - ClientDOB = ClientAge </p>
  
  <p>Here is my code:</p>
  
  <pre><code>var DateToday_ = Date2Num(DateToday.formattedValue, "MM/DD/YYYY")
  var ClientDOB_ = Date2Num(ClientDOB.formattedValue, "MM/DD/YYYY")
  var diff = DateToday_ - ClientDOB_
  ClientAge.value = Floor(diff / 365.25)
  </code></pre>
  
  <p>I am not sure why the ClientAge field will not populate once the ClientDOB has been selected. Any replies would be helpful. Thanks. </p>