I have a form of type date, and I need to generate the 'min' and 'max' it according to the current date. I made a function that calculates that date and arrow it in the form. The problem is that the value of the day is coming with 1 home and in html I need two homes. Here is the function:
function getDataMinima(){
var dataMinima = new Date();
dataMinima.setFullYear(dataMinima.getFullYear()-130);
var dataForm = dataMinima.getFullYear() + '-' + dataMinima.getMonth() + '-' + dataMinima.getDate();
console.log("entrou na função minima, data calculada:"+dataForm);
var dataMaxima = new Date();
dataMaxima.setFullYear(dataMaxima.getFullYear()-5);
var dataMaximaForm = dataMaxima.getFullYear() + '-' + dataMaxima.getMonth() + '-' +dataMaxima.getDate();
console.log("Entrou na funcao maxima, data calculada:"+dataMaximaForm);
$("#campodata").attr({
"min" : dataForm
});
}
My problem is that when this value is passed to html, I get: '1888-11-3', and '3' instead of '03' causes the rule to be ignored, is there any way to format this?