Quantcast

triggering contextual error message for inputs

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

triggering contextual error message for inputs

Xavier Mouton-Dubosc-2
Hi everyone

I'm actually dev'ing on a intranet application in HTML5 with XHR (so
sorry, but i can't give access to any example)

For a <form> I wish on make an XHR, I test the validity of the form,
like this :

if (form.checkValidity())
{
  $.post([...]);
} else {
   errormessages();
}

on the same way, into the return of the post (the [...] part), i can
have error validating messages from the server. So I attach them to
the inpts like this :
input.setCustomValidity(le_error_message);
le_error_message is really attached as I can see into
input.validationMessage
the :invalid css selector is set to the input but...

How can I trigger the browser (firefox, chrome, etc...) to display
their standard contextual error-message ?

I tried form.submit(), but it will really submit the form, even
skipping what I wish the browser should do.
I can't see any reference to that in MDC, nor into inspecting <input>
and <form> elements.

Sorry my french.
Xavier Mouton-Dubosc
  http://Dascritch.com
  @dascritch
_______________________________________________
dev-tech-dom mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-dom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: triggering contextual error message for inputs

Mounir Lamouri-3
First of all, sorry for the quite late reply...

On 02/09/2012 04:14 PM, Da Scritch wrote:
> How can I trigger the browser (firefox, chrome, etc...) to display
> their standard contextual error-message ?

Unfortunately, you can't really do that. form.submit() will by-pass the
form validation check. The only way to trigger the form validation check
is when the user tries to submit the form. IIRC, there was a discussion
on whatwg about adding a way to trigger the browser's form validation
check (and the UI) but I can't find it...

Cheers,
--
Mounir
_______________________________________________
dev-tech-dom mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-dom
Loading...