"make a check before sending to the bank that does not allow the first date to be greater than the second"
You can do this in 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 some of the various JS libraries. I use datepicker of jquery.
This application allows multiple settings of the date field quite simply.
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 that date is chosen, the date of the party can only be greater than or equal to the date of arrival. There is also the possibility of the user to choose the date of the party first. So the product's maximum delivery date can only be the date of the event.
Hope it helps, try to fit 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 );
}
});