onSubmit returning false is not working

Posted by StuckOnSubmit on Stack Overflow See other posts from Stack Overflow or by StuckOnSubmit
Published on 2010-03-30T09:04:11Z Indexed on 2010/03/30 9:13 UTC
Read the original article Hit count: 312

Filed under:
|
|

I'm completely confused ... I'd swear this was working yesterday ... I woke up this morning and all my forms stopped to work in my project.

All the forms have a "onsubmit" to a function that returns false since it's an ajax call, so the form is never sent.

After a lot of tests, I simplified the question to this piece of code:

<html>
<head>
<script type="text/javascript">
 function sub()
 {
  alert ("MIC!");
  return false;
 }
</script> 
</head>
<body>

<form method = "post" id = "form1" onsubmit = "return sub()">
 input: <input type="text" name="input1" >
    <a href="#" onClick="document.getElementById('form1').submit();">button</a> 
</form>

</body>
</html>

I would swear that this works perfectly, but today is nor working :D

Why if I press the button the form is sent ?

I know it's a total newbie question, but I'm stuck

Thank you !

© Stack Overflow or respective owner

Related posts about onsubmit

Related posts about return