8
How can I check if a post is of the type date
?
There was 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 check if sending the $_POST['data']
is a valid date.
One problem that happened is that Mozilla firefox leaves an open field for the user to type. In google Chrome and edge I no longer have this problem.
Another problem is if the user goes to the element inspecter and changes the input type date
for text
. If it sends the form with some incorrect value (e.g. single quote, letters) will give error at the time of the query.
My intention is to validate the date after it is sent by the form. How can I do that?
OBS.: I’m using php
Your solution worked out!
– DiChrist