SUM DAYS TO date

by Cristian Camilo Uribe Pulido

HTML

<input type="text" id="USER_joindate" placeholder="yyyy-mm-dd"/>
<input type="text" id="EndPeriodExperience" readonly/>

JavaScript

$( document ).ready(function() {
    $("#USER_joindate").on("change", function(){
       var date = new Date($("#USER_joindate").val()),
           days = parseInt($("#days").val(), 10);
        
        if(!isNaN(date.getTime())){
            date.setDate(date.getDate() + 61);
            //2012-12-17
            $("#EndPeriodExperience").val(date.toInputFormat());
        } else {
            alert("Fecha Invalida");
            $("#USER_joindate").focus();
        }
    });
    
    Date.prototype.toInputFormat = function() {
       var yyyy = this.getFullYear().toString();
       var mm = (this.getMonth()+1).toString(); 
       var dd  = this.getDate().toString();
       return yyyy + "-" + (mm[1]?mm:"0"+mm[0]) + "-" + (dd[1]?dd:"0"+dd[0]);
    };
});