0
I have a question. I need to fix a date in a form, but if the field is empty, it goes straight through the function and does not execute. If it is previously completed, it makes the change.
Initially I did so, without the validation of the empty field:
$(document).ready(function AcertaDataInsp() {
var data = $("#dataInspecao").val();
var aData = data.split("-");
var datacompleta = aData[2]+'/'+aData[1]+'/'+aData[0];
$("#dataInspecao").val(datacompleta);
});
My question is, how do I perform the function only if the field is filled? Today if I execute the function above, in the form it fills so "Undefined/Undefined/"
It worked this way. The detail of the undefined field is gone. I will test in filled date situations as well.
– William Kiefer