How can I check if a post is of type date
?
There has been a situation where I have a form that contains a date field:
<form action="" method="post">
<input type="date" name="data">
<input type="submit" name="enviar" value="enviar"/>
</form>
I need to make sure the sending of $_POST['data']
is a valid date.
One problem that has happened is that mozilla firefox leaves a field open to the user typing. In google chrome and in edge I no longer have this problem.
Another problem is if the user is in the element inspector and change the input type date
to text
. If it sends the form with some incorrect value (eg single quote, letters) it will give error at the time of the query.
My intention is to validate the date after it is submitted by the form . How can I do this?
NOTE: I'm using php