Alex Rivera | Logout

onSubmit returning false is not working

Asked 2010-03-30T09:04:11.230
15

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 !

Edit
Report

1 Answer

-4

Check basic syntaxes and structures... then Check your other forms on your page or input boxes with no form... I had the same problem (or similar: pressing enter in the input box would cause the form to send) ...

I copy pasted the samples above and loaded the page. They worked and mine did not, so i tweaked the formatting and even rewrote it.

answered 2013-03-05T02:43:13.603

Your Answer