Hello!
How to check these input?
Now it works only on the first thing to do, what would both be checked at any moment?
<script> function formatDate(){ str = document.getElementById('Date').value; var err=[] function TstDate(){ str2=str.split("."); if(str2.length!=3){return false;} str2=str2[2] +'-'+ str2[1]+'-'+ str2[0]; if(new Date(str2)=='Invalid Date'){return false;} return str; } var S=TstDate() if(S){err.splice(0,1); document.getElementById("output").innerHTML = " "; } else { document.getElementById("output").innerHTML = "Введите правильно дату"; }; } </script> <div class="input-inner"> <form> <input type="text" id="Date" placeholder="00.00.0000" class="firstDate" name="firstDate" onchange="formatDate(this.value);"> <input type="text" id="Date" placeholder="00.00.0000" class="secondDate" name="secondDate" onchange="formatDate(this.value);"> </form> <span id="output"></span> </div>