"make a check before sending to the bank that does not allow the first date to be greater than the second"
You can do it two different ways:
- Back end - php
- Front end - javascript
I usually use javascript to avoid code in php.
That said, using JS, there are at least 2 possibilities for this task.
- Using pure javascript
- Using one of the various JS libraries. I use datepicker jquery.
This application allows multiple date field settings in a very simple way.
I have a code that I use in my applications. It is bi-directional.
In the following scenario there is a date to deliver products and a date to relaunch the party. Then the user chooses the expected date to receive the product. When this date is chosen, the date of the feast may only be greater than or equal to the date of arrival. There is also the possibility for the user to choose the date of the party first. So the maximum date of delivery of the product can only be the date of the event.
Hope it helps, try to suit your needs.
//Validar datas:
//Quando abre o datapicker seleciona a menor data para ser o dia de hoje now().
var now = new Date(),
minDateJS = now.toISOString().substring(0,10);
//Seleciona a data de entrega do produto.
//Aplica a data now (hoje) para ser a menor data selecionavel para a entrega do produto
//Aplica a data de entrega do produto para ser a menor data possivel do evento
$('#dt_entregaProd').datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true,
minDate: minDateJS,
inline: true,
onClose: function( selectedDate ) {//Passa a data selecionada neste objeto para ser a menor data possivel para realizar o evento
$( "#dt_Event" ).datepicker( "option", "minDate", selectedDate );
}
});
//Seleciona a data do evento.
//Evento bidirecional. Se a data do evento for selecionada primeiro, entã a data máxima de entrega do produto será limitada automaticamente
$('#dt_Event').datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true,
minDate: minDateJS,
inline: true,
onClose: function( selectedDate ) {
$( "#dt_entregaProd" ).datepicker( "option", "maxDate", selectedDate );
}
});
You’re doing it the hard way. I’ll try to help you
– Wallace Maxters
Okay Wallace Thanks :D
– Nikk 17016