I'm building a html5 form. To validate it at first I use html5 validate mechanisms (patterns, required, etc...), and then PHP server side validation. I'm writting it as a library, so I can't predict all possible cases.
For example, I've got email input:
<input type="email" name="mail" placeholder="[email protected]" />
Now I'm checking with php if the domain: domain.com exists (* - see footnote).
If no, PHP render the form once more but should display error near the input that has validation mistakes.
HOW TO DO THAT SEMANTICALY? What html element is good for it?
I will give some wrong examples to ilustrate my problem (I will write only important fragments of code) :
<label for="mail">Email:</label>
<input type="email" name="mail" id="mail" /> - given mail does not exist
Error without of html5 element. This is what I found to be most popular on websites, and most hopeless (stupid - no offense :) ) solution...
<label for="mail">Email (given mail does not exist):</label>
<input type="email" name="mail" id="mail" />
Is the error realy a label fragment? Or label is label, and error is not a fragment of label. In that case labels can be diferent (according to a given mail). Is this semantic?
<label for="mail">Email</label>
<input type="email" name="mail" id="mail" />
<span class="error">Given mail does not exist</span>
No idea solution. Span can be used here, but this is another no better idea solution.
Another ideas:
<details>- this isn't a detail...<aside>- this isn't aside, this is important!<mark>,<strong>,<emph>- with a given class?
Thanks for Your time and ideas. I know that even complicated error handling can be done using html5 validation methods, but there should be an object that is the best for showing such things in html5 semantic (for example for blind people - imagine the screen reader application, form filling by such a person by voice, and the first stupid solution usage. The screen reader should read whole page to hear just one error...)
Best regards
PS. If someone think, that there are better problems on earth (:D), yes of course there are. But we are those, who try to make the web more clean and available. And we really should take care about such details.
(*) which is not that easy in html5 You must use ajax, with php function, and override default Error handling mechanisms with Your own texts, and much much more...).