HTML Forms without actions

27,825

Solution 1

Having an action of an empty string in most browsers points the form at the URL the browser currently has loaded, which is the script that served the form in the first place.

Solution 2

For an interesting insight on forms with empty actions read this thread, which gives you an updated HTML5-perspective on this matter.

Solution 3

It's also possible that javascript loaded with this page could be setting an action once the page is loaded based on what application is using the page.

Another likely possibility is that the javascript is handling the onsubmit event. One might do that to prevent the page from reloading or redirecting to a specific page

Share:
27,825
interstar
Author by

interstar

I'm a programmer, teacher and digital artist. See http://sdi.thoughtstorms.info/ for most of my programming related thoughts.

Updated on November 21, 2020

Comments

  • interstar
    interstar over 3 years

    In Django / Pinax, I've come across the login form which starts like this :

    <form class="login" method="POST" action="">
    

    It works perfectly well. So I assume that either some java-script or something in the Django framework is putting the value into the action attribute.
    So, my questions:

    • How does Django insert the action?
    • Why do they do it like this?
    • How can I find out what the action of this form is?

    Update : I see this is not a Django thing at all, but what most browsers do.