I have a scenario in which I have 2 Submit Buttons in a form for going back and forward.
Both the buttons have different JavaScript associated with it. It is working great if we press these buttons to navigate.
But when in Google Chrome, when someone press enter on any of the text box within the Form it does not calls the onClick of the button.
Is there any work around for that.
Thanks
You’ll need to hook the
keypressevent and look for key code 13, unfortunately. Not all browsers (in fact, virtually none I think) will trigger theclickevent on a submit button if you didn’t actually click the button. They will trigger thesubmitevent on the form.So the pattern becomes: Put the validation (et. al.) you want to run when they click the default submit button in a function, and call that function from the
keypressevent if the key code is 13 and there are no modifier keys down, and from theclickof that button.When dealing with keyboard events, I find this page invaluable.