0
How do I make for the <input type="text" name="calendar" id="calendar">
accept only correct dates, example of a correct date 01/02/2017 but it is accepting when type 01/20/2017, ie the month 20 does not exist, the type
of <input>
must continue with "text", follow the example with the problem.
$(document).ready(function(){
$('#calendar').mask('99/99/9999');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>
<input type="text" id="calendar" name="calendar">
Why it needs to be text?
– Thiago Santos
@Thiagosantos why it could not be text?
– MarceloBoni
It could be "date".
– Thiago Santos
This isn’t HTML5 it’s just jQuery.
– Guilherme Nascimento
@Thiagosantos besides being js, type="date" does not work in Firefox, IE and Safari: http://caniuse.com/#search=input%20date
– Pliavi
date does not work in firefox, so the alternative was to use the jquery mask.
– WMomesso
@Wagnerfernandomomesso I wrote a solution (below) using JS and without changing "text" that erases the field if the date does not exist, can check?
– Thiago Santos