1
I don’t have much knowledge with javascript and I don’t know how How can I Open a Modal window if difference between two dates is equal to X days Exe.
(If clicking on the chosen field and date has a difference of 1 day from the current date open modal1)
(If clicking on the chosen field and date is earlier than the current date open modal2)
I have this script below
<?
date_default_timezone_set('America/Sao_Paulo');
$data_atual = date('Y-m-d');
?>
<input type="datetime-local" name="start" value="2015-03-23 00:00:00" />
<a href="#modal-simple1" data-toggle="modal" class="btn btn-primary">Abrir</a>
<!-- Modal 1 -->
<div class="modal fade" id="modal-simple1">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal heading -->
<div class="modal-header">
button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
</button>
<h3 class="modal-title">Modal header</h3>
</div>
<div class="modal-body">
<p>
</p>
</div>
<div class="modal-footer"><input type="checkbox" /><font color="black"> Li e aceito
os termos para compra e uso do(s) serviço(s) acima citado(s).</font></h4>
<input type="submit" value="Confirmar Compra" class="btn btn-block btn-danger btn-
icon glyphicons home" />
</div>
</div>
</div>
</div>
<!-- // Modal END -->
<a href="#modal-simple2" data-toggle="modal" class="btn btn-primary">Abrir</a>
<!-- Modal 2 -->
<div class="modal fade" id="modal-simple2">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal heading -->
<div class="modal-header">
button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
</button>
<h3 class="modal-title">Modal header</h3>
</div>
<div class="modal-body">
<p>
</p>
</div>
<div class="modal-footer"><input type="checkbox" /><font color="black"> Li e aceito
os termos para compra e uso do(s) serviço(s) acima citado(s).</font></h4>
<input type="submit" value="Confirmar Compra" class="btn btn-block btn-danger btn-
icon glyphicons home" />
</div>
</div>
</div>
</div>
<!-- // Modal END -->
It is not working.. The modal does not open. I changed this line to: var data_input = new Date($(this).val()); //field date and the modal now working longer opens at any date that chooses what may be?
– Fabio Henrique
Missed closing the constructor, I’ll edit the answer. I’m glad it worked.
– lfarroco