OK, the name is so strange that I must, of course, say what happens :). I am creating an HTML5 form. I want this form to be fully validated using the new HTML5 methods and the new CSS3 pseudo-classes (of course, I remember server-side validation). I will give an example:
HTML:
<input type="email" value="">
CSS
input:invalid {color: #fff; box-shadow: 0 0 5px #f00;}
As we all know: a good check is the same as in the users browser and on the server. Therefore, if I allow the user to enter only the email number, and the server will accept emails, this is an error. If the user can enter the numbers and the server does not accept it, this will be an error.
What is the problem? I ask the user to send an email. The user enters asd @asd, which perfectly checks email in the HTML5 nomenclature (asd can be localhost, so the point is not needed). That's why the entry is confirmed, and everything is in order. Now I am sending this email to my PHP script, which is MUCH MORE REQUIRED. For example, he:
Php
function Validate($mail) {
$validate = true;
if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) $validate = false;
$host = explode('@',$mail);
$host = array_pop($host);
if ($host == '') $validate = false;
else if (!checkdnsrr($host,'MX')) $validate = false;
return $validate;
}
Therefore, asd @asd email, of course, does not pass this check.
Is there any mechanism that allows me to suggest to the browser that this email is still not very good, but using HTML5 methods?
More precisely. I wrote a PHP form class that first validates the POST data and then displays the form. Therefore, if something is missing, I can display the form, but using the POST data so as not to forget the input values. This is a common method for doing this.
, , PHP , , HTML5 . ( , ...):
$email = isset($_POST['email']) ? $_POST['email'] : '';
if (Validate($email)) {
header("Location: /success-congratulations-great-form-hoooray");
}
else {
echo "<form>...";
echo "<input type="email" value=\"$email\">";
echo "<input type=\"submit\" ... />
echo "</form>";
}
. ? - - <script>, . .
, , , , , , -...
!
UPDATE
, ? , :).