[html5] onclick vs. onsubmit

Joseph Oreste Bruni jblist at me.com
Thu Mar 24 14:25:36 PDT 2011


Sorry. Here is the html boiled down to a test case:


<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<form>
<p><input type=submit onclick="return confirm('Allow?')"></p>
</form>
</body>
</html>


The error message is as follows:

Error: Bad value return confirm('Allow?') for attribute onclick on element input: invalid return
From line 8, column 4; to line 8, column 57
<form>↩<p><input type=submit onclick="return confirm('Allow?')"></p>↩<


Perhaps only the validator is invalid?




On Mar 24, 2011, at 2:15 PM, Randy Drielinger wrote:

> What was the exact error message? That helps :)
> 
> ------Original Message------
> From: jblist at me.com
> Sender: help-bounces at lists.whatwg.org
> To: help at lists.whatwg.org
> Subject: [html5] onclick vs. onsubmit
> Sent: Mar 24, 2011 22:03
> 
> Hi folks,
> 
> I have a form with two submit buttons. Based on which submit button is clicked, I'd like to present different confirmations prior to allowing the submission to proceed. Originally, I just used the onclick attribute with a function that essentially called confirm(). Returning false would cancel the submission. Each button had its own click event handler and everything was working as expected.
> 
> However, in attempting to make sure my markup is correct, I passed my page through the validator which complained about the return value in the click event handler. The error message was a bit cryptic, but I'm assuming that click events are not supposed to be cancelable (even though the browsers let me do that).
> 
> To do the "right thing" I figured I need to hook my javascript into the submit event stream instead. However, how can I determine which submit button fired the submission? Is this encoded in the submit event? Is there some state in the button itself I can query from the event handler? What's wrong with returning false from the click event handler to stop the form submission?
> 
> Best regards,
> Joe
> 
> _______________________________________________
> Help mailing list
> Help at lists.whatwg.org
> http://lists.whatwg.org/listinfo.cgi/help-whatwg.org
> 




More information about the Help mailing list