davideuler / pwm

Automatically exported from code.google.com/p/pwm
0 stars 0 forks source link

Enter key behaviour cancels form submit IE/ Chrome #507

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When the focus is on an HTML form, and the user presses the ENTER key, by 
default, Internet Explorer (tested version 9) and Chrome (tested version 29) 
treats this action as if the user wants to submit the form. This behavior is 
fine.

However in some forms (i.e. Change Password, Setup Responses) the input type 
submit is disabled because of field validations. In this particular case 
pressing the Enter key leads to pressing the "cancel" button element on that 
page. Because the button tag is, by default, type="submit" it is executing that 
button when the Enter key is pressed. 

Fix:
IE9 and Chrome counts the <button/> element as type="submit" by default. So to 
make it non-submit, we have to be explicit for at least the cancel buttons on 
all JSP's:

old siutation
<button style="visibility:hidden;" name="button" class="btn" id="button_cancel" 
onclick="handleFormCancel();return false">

new situation
<button type="button" style="visibility:hidden;" name="button" class="btn" 
id="button_cancel" onclick="handleFormCancel();return false">

attached

Original issue reported on code.google.com by sebastia...@gmail.com on 6 Nov 2013 at 3:14

Attachments:

GoogleCodeExporter commented 9 years ago
added patch to revision 639, excellent, thank you!

Original comment by jrivard on 11 Nov 2013 at 5:05