javascript - Why is my form doing other things than what I told it to do on submit? -


I have broken some code from a website and I have my input element (because it is a server Was causing the error). So what I did is change verb to "" and onsubmit = "myFunction () " add what I have

  & lt; Form method = "get" name = "formname" action = "" onsubmit = "myfunction ()" & gt; .... & lt; / Form & gt;  

and

  function myFunction () {Warning ("Well, my work was called"); }  

I have confirmed that when I enter input , the alert function is called. However, the error of the saver is that the form is still going on after right click on the alert.

Why could it be any thoughts? Basically, I am trying to create myfunction , only when form is served.

Either you need to call preventDefault () or Return the call to the function, otherwise it will execute default behavior either submit the form.

Either it's like.

  function myFunction () {Warning ("Well, my work was called"); return false; }  

and return my function in the calling function () .

or use preventDefault


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -