Reputation: 198178
The html code is simple:
<form onsubmit="submitAdvice(this);return false;">
<input type="submit" value="submit" />
</form>
And the javascript code:
function submitAdvice(f) {
alert('submitting');
}
But when I click the submit
button, it doesn't alert submitting
, instead, it submits the form.
I don't know where is wrong.
PS: the live demo: http://jsfiddle.net/yc6cq/
I just found the reason, it caused by jsfiddle!
Please note it will load mootools 1.4.5
on onLoad
event. Everything will be OK if I set it as no wrap
Upvotes: 1
Views: 14296
Reputation: 104
Try with this form statement
<form onsubmit=" return submitAdvice(this);">
Upvotes: 0
Reputation: 6147
<form onsubmit="return submitAdvice(this);">
<input type="submit" value="submit" />
</form>
function submitAdvice(f) {
alert('submitting');
return false;
}
Upvotes: 4