Hello! There is a code:
<div class="input-inner"> <form> <input type="date" class="firstDate" name="firstDate"> <input type="date" class="secondDate" name="secondDate"> </form> </div>
How to use JS to receive data on the go? Those. without clicking a button
Check for correct dates in the fields and comparisons of these two dates?
var firstDate = document.getElementsByClassName("firstDate")[0].value; var secondDate = document.getElementsByClassName("secondDate")[0].value; function formatDate(date) { var dd = date.getDate(); if (dd < 10) dd = '0' + dd; var mm = date.getMonth() + 1; if (mm < 10) mm = '0' + mm; var yy = date.getFullYear() % 100; if (yy < 10) yy = '0' + yy; return dd + '.' + mm + '.' + yy; } var d = new Date(2014, 0, 30);
Here there is such code, but I don’t put my mind on what to do with it, I would do it with jquery, but here it’s necessary on pure JS How to check this data using the formatDate function