Here is a snippet of my form
<form action="" method="post" onsubmit="return verify()">
        <input type="submit" name="submit" value="Delete" />
        <input type="submit" name="submit" value="Save" />
</form>
As you can see I am verifying with a function called verify(). I only want to verify if they 开发者_开发问答click "save", I do not want to verify for "delete".
How can I do this? Is there a way I can tell which one they clicked inside the funciton and just return true if they clicked "delete"? 
Place return verify(); in the onclick of the button.
You can use a global var.
HTML
<form action="" method="post" onsubmit="return verify()">
        <input type="submit" name="submit" value="Delete" onclick="window.action='delete'"/>
        <input type="submit" name="submit" value="Save" onclick="window.action='save'" />
</form>
JS
var action = '';
function verify() {
    if (action == "save") {
        // validates
    }
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论