Use a normal link to submit a form
Here's the shortcut to submit your form using a JavaScript-enhanced link:
Just update the form and anchor IDs ('form-submit-link'
and 'cunning-form'
respectively) to match your reality.
Styling your submit button as a link
Disguise your submit button as a friendly, non-threatening link using CSS wizardry:
These styles strip the button of its usual business attire and dress it up as a casual link.
Deploying image-based submit buttons
In the above script, the selected image also doubles as the Bat-Signal, calling form's submit()
method to action.
Submit action via JavaScript EventListener
Deploy your JavaScript sidekick with an EventListener
for more form control:
Advanced form control with AJAX
In this approach, our link gets souped-up with AJAX capabilities, à la Batmobile.
Accessibility Matters
For accessibility reasons, consider using a <button>
element and styling it as a link:
This maneuver lets screen readers in on the action, rendering your web page more inclusive.
Was this article helpful?