How do i put an onclick and a return false statement in the same submit button?

后端 未结 4 1234
走了就别回头了
走了就别回头了 2020-12-06 17:51

From what i understand, the default treatment for return false is:


However in my c

相关标签:
4条回答
  • 2020-12-06 18:24

    Like this:

    <input type="submit" onclick="jsfunction();return false;" />
    

    or just use a button intead of a submit button:

    <input type="button" value="Submit" onclick="jsfunction();" />
    
    0 讨论(0)
  • 2020-12-06 18:27

    try to add your method (jsmethod) to your form onsubmit handler like this

    <form onsubmit="jsfunction(); return false;">
    

    and remove the input onclick handler.

    0 讨论(0)
  • 2020-12-06 18:36

    just do like this

    <input type="submit" onclick="return jsfunction()" />
    

    change in function

    function jsfunction()
    {
      //you code 
      return false;
    }
    

    or just try if you dont want to change function

    <input type="submit" onclick="jsfunction();return false;" />
    
    0 讨论(0)
  • 2020-12-06 18:47

    No you cannot have 2 onclick declarations but you can call multiple functions in the same onclick like:

    <input type="submit" onclick="jsfunction();anotherFunction();" />
    

    And in the other function you can have:

    function anotherFunction(){
      return false;
    }
    
    0 讨论(0)
提交回复
热议问题