form validation plugin question.

form validation plugin question.

I have a form with 2 buttons: 'Update' and 'Delete'. The form also has a custom submit handler. Update button goes through the validation process and ends up in handler while the Delete button bypasses the validation and ends up at the same place. Now in my handler code I need to detect which button is actually got me here so that I would take an appropriate action.

Here is what I come up so far, but I just want to see if there is a cleaner way to do it and if my approach has some potential problems I am not aware of:

           <div id="ControlDiv">
                <input type="image" src="/img/update.png" value="update" onclick='javascript:setAction("update");'/>
                <input type="image" src="/img/delete.png" onclick='javascript:setAction("delete");' value="delete" class="cancel" />
            </div>
                                                                 
        </fieldset>
    </div>
<% } %>

<script type="text/javascript">

   var action = "";

   function setAction(value)
   {
       action = value;
   }

    $(document).ready(function () {
        $("#NewUser").validate({

            submitHandler: function () { alert(action); }

        });
    });

</script>