Prabin Poudel Prabin Poudel - 5 months ago 38
Javascript Question

Get the largest value from two DOB input fields

I have following input field for DOB.

<div class="po.pependent">
<input type="text", class="zm-textbox dob-input-mask" placeholder="dd/mm/yyyy" />,
<input type="text", class="zm-textbox dob-input-mask" placeholder="dd/mm/yyyy"/></div>

So if enter dob 11/12/1999 and 11/12/1997 the function paymentForm.computeAge return 17 and 19.

Now in JS i am trying to get the value of these to Dob convert them and get the highest age among the two dob entered.

.each(function() {

return the calculated age from the given dob date comparing with current system date.

Answer Source

You need to use Math.max. Below are 2 ways of doing it:

console.log(Math.max(17, 19));

var ageArray = [17, 19]
var max_of_array = Math.max.apply(Math,;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download