I have a textfield which takes date of birth as input from user. In another textfield i want to set the age calculated. However, the current date and date of birth are in different formats.
 Current Date 
   
     Date of birth 
       
    
     Age 
     
The javascript function is as follows:
function todayDate(){
       var currentDate = new Date();
    var day = currentDate.getDate();
    var month = currentDate.getMonth() + 1;
    var year = currentDate.getFullYear();
    document.getElementById("date").value = (day + "/" + month + "/" + year);
       }
function ageCalculation(){
       var currentDate = new Date();
    var birthDate = document.getElementById("dob").value;
    alert(birthDate);
    var difference = currentDate - birthDate;
    document.getElementById("age").value = difference ;
       }
In textfield of age I am getting "NaN"
 
     
    