Convert all submit input onclick handlers to onsubmit handlers

Description

Using onClick handlers on submit inputs in forms is problematic for several reasons:

  • Some versions of IE seem to either ignore the onclick handler or improperly submit the form when this pattern is in place. When I was testing this week, I could not reproduce the problem on IE8 but I do remember fixing this issue on older versions so it may affect IE6 and/or IE7.

  • If a user hits the ENTER key on a form input, the onclick of the submit button will NOT be triggered so all of the nifty validation Javascript will be ignored. In many cases, this will lead to HTTP-500 errors because the form gets submitted with incomplete params or to an unexpected URL (if you are manipulating the form action inside Javascript).

  • Conceptually, it makes more sense to use an onsubmit handler on the form. The onsubmit function that is invoked must return a boolean value. "true" indicates that the form submission should be POSTed to the server, "false" means that the POST operation should be halted (for instance, on Javascript validation errors). You also shouldn't explicitly call document.myform.submit() inside the Javascript; just let the browser figure out that by returning "true", you wish for the form submission to continue.

We should comb through the UI and make these changes; this will eliminate a lot of confusing bugs, especially since users may see the bug when hitting ENTER on a form but not see it when using the mouse which gives the outward appearance of a frustrating intermittent failure.

Environment

Operating System: Linux Platform: PC

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

Seth Leger (community account) September 23, 2010 at 5:28 PM

I've changed all of these instances over to onsubmit handlers or button/onclick inputs. This should make the behavior reliable on any browser. Marking as fixed.

commit 8ced5a3bd46c39e3e4446ffb720ed002f9bb035f

Seth Leger (community account) March 4, 2010 at 1:05 PM

Full list of pages with submit/onclick:

  1. grep -i 'type="submit"' `find opennms-webapp/src -name "*.jsp"` | grep -i onclick | cut -d ':' -f 1 | uniq
    opennms-webapp/src/main/webapp/admin/nodemanagement/managenode.jsp
    opennms-webapp/src/main/webapp/admin/nodemanagement/setPathOutage.jsp
    opennms-webapp/src/main/webapp/admin/nodemanagement/deletenode.jsp
    opennms-webapp/src/main/webapp/admin/snmpConfig.jsp
    opennms-webapp/src/main/webapp/admin/pollerConfig/addPollerConfig.jsp
    opennms-webapp/src/main/webapp/admin/pollerConfig/index.jsp
    opennms-webapp/src/main/webapp/admin/userGroupView/users/newUser.jsp
    opennms-webapp/src/main/webapp/admin/userGroupView/users/newPassword.jsp
    opennms-webapp/src/main/webapp/admin/userGroupView/views/modifyView.jsp
    opennms-webapp/src/main/webapp/admin/newInterface.jsp
    opennms-webapp/src/main/webapp/admin/discovery/edit-config.jsp
    opennms-webapp/src/main/webapp/admin/discovery/add-specific.jsp
    opennms-webapp/src/main/webapp/admin/discovery/add-ir.jsp
    opennms-webapp/src/main/webapp/admin/discovery/add-er.jsp
    opennms-webapp/src/main/webapp/admin/discovery/add-url.jsp
    opennms-webapp/src/main/webapp/admin/notification/pathOutline.jsp
    opennms-webapp/src/main/webapp/admin/notification/destinationPaths.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/admin/userGroupView/groups/modifyGroup.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/admin/userGroupView/groups/newGroup.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/admin/thresholds/editExpression.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/admin/thresholds/editThreshold.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/admin/storage/storageAdmin.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/admin/rancid/rancidAdmin.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/graph/chooseresource.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/KSC/customGraphEditDetails.jsp
    opennms-webapp/src/main/webapp/WEB-INF/jsp/KSC/customReport.jsp

Seth Leger (community account) March 4, 2010 at 12:58 PM

Marking several bugs that I believe are blocked by this issue.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

PagerDuty

Created March 4, 2010 at 12:56 PM
Updated January 27, 2017 at 4:26 PM
Resolved October 13, 2010 at 10:57 AM