PDA

View Full Version : How to check which button is clicked?


buckbeak
09-27-2002, 08:20 AM
I have 2 buttons which when submit form if will perform different js function (validation).

function check(){
if save button is clicked {if (form.name.value == '') {
alert("This field cannot be blank");}

}


<form onSubmit="return check()">
2 buttons - save and delete
</form>

Roelf
09-27-2002, 09:09 AM
add a hidden field to the form. Add an onclick event handler to the two buttons which puts a value in the hidden field. When the form is received, you can detect the button clicked by the value of the hidden field