I want to compare the user\'s birthday against today\'s date and get the number of days in between. The birthday they enter will be in the form of 12/02/1987 in an
I wrote a lightweight date library called Moment.js to handle stuff like this.
var birthday = moment('12/02/1987', 'MM-DD-YYYY');
var inputDate = moment(element.value, 'MM-DD-YYYY');
var diff = birthday.diff(inputDate, 'days');
http://momentjs.com/docs/#/displaying/difference/
You'll need to first parse element.value
as a date:
difference = today - new Date(element.value);
http://jsfiddle.net/gilly3/3DKfy/