0
Fala galera...
Next, I need to implement a student’s "Suspend Contract" option. This suspension may only be applied within the term of the student’s contract. Assuming that the student has his contract valid from 01/01/2020 until 31/12/2022 and the suspension of this contract should ONLY be applied between these two dates.
I have the code below, but I don’t know where or what’s wrong.
<script language="javascript">
function checarDatas()
{
var dataCI = (document.forms[0]["contratoIncio"].value).split("/");
var dataCF = (document.forms[0]["contratoFim"].value).split("/");
var dataSI = (document.forms[0]["suspensaoInicio"].value).split("/");
var dataSF = (document.forms[0]["suspensaoFim"].value).split("/");
var dataInformadaSI = new Date(dataSI[2], dataSI[1]-1, dataSI[0]);
var dataInformadaSF = new Date(dataSF[2], dataSF[1]-1, dataSF[0]);
var dataInformadaCI = new Date(dataCI[2], dataCI[1]-1, dataCI[0]);
var dataInformadaCF = new Date(dataCF[2], dataCF[1]-1, dataCF[0]);
if ( dataInformadaSI >= dataInformadaCI && dataInformadaSF <= dataInformadaCF )
{
alert("Datas OK!");
}
else
{
alert("A data de suspensao escolhida, esta fora da vigencia do contrato.");
document.getElementById('suspensaoInicio').value="";
document.getElementById('suspensaoFim').value="";
}
}
</script>
My page is in PHP. I have a query that brings from BD the contract dates in the format "yyyy-mm-dd".
I hope I was clear.
Thank you who can help!