웹접근성을 고려한 Form URIs
This technique relates to the following sections of the guidelines:
Task:
Avoid javascript: URIs for form actions.
Setting the action attribute in a form to a javascript: URI causes non-script-capable browsers to fail silently.
Deprecated Example:
This example code shows a problematic use of the javascript: URI:
<form action="javascript:submitmyform()"> ... </form>
Deprecated Example:
Another common error is to point the form's action to "#" (the top of the current document), while using the onsubmit event. This causes users of non-script-capable browsers to become confused, as their repeated activation of the submit button does nothing.
<form action="#" onsubmit="submitmyform()"> ... </form>
Example:
The correct method for firing an ECMAScript function when a form is submitted is to use the onsubmit event. The checkFormFields() function would return true if there are form errors, stopping the submission of the form:
<form action="submit.php" onsubmit="return checkFormFields();"> ... </form>