3
I’m getting in a date value variable on string
and making the conversion to date, to be able to make a condition. The problem is that when the date comes as 31/12
, the variable gets NaN
.
Follow the example below:
function ValidaDataVersao(escopoGrade)
{
debugger;
dataInicial = Date.parse(escopoGrade.registroSelecionado.DataInicial);
dataFinal = Date.parse(escopoGrade.registroSelecionado.DataFinal);
let sequenciaValida = true;
if (dataInicial > dataFinal) {
smartBox.Alerta(null,
'Cancelado!',
"Data Inicial deve ser menor que Data Final.",
6000);
sequenciaValida = false;
return false;
}
return sequenciaValida;
}
let escopoGrade = angular.element('#gradePerfilECDVersoes').scope();
if (escopoGrade)
{
escopoGrade.adicionarCriticas(function () {
return ValidaDataVersao(escopoGrade);
});
}
If the date comes on string
for 31/12/2020
, for example the variable is as NaN
and then I can’t make the comparison.
Congratulations bro! That was the only way it even worked. Thanks.
– richard oliveira