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:
Update : I see this is not a Django thing at all, but what most browsers do.
Yes, the form is required to have an action attribute in HTML4. If it's not set, the browser will likely use the same method as providing an empty string to it. You really should set action="" which is perfectly valid HTML4, follows standards, and achieves the same exact result.
There is a method in Javascript to remove this functionality of the HTML form which name is preventDefault(). preventDefault() method of Javascript can be used with two events - onclick & onsubmit. You need to write something in function's parameter to examine the event to disable it.
If action is set to "" or if the action attribute is missing, the form submits to itself. That is, if your script is index.
Is the action Attribute Required? Back in HTML4, the answer would be yes. Nowadays with HTML5, you are not required to specify an action attribute. If you have a form tag without an action attribute then the data will be sent to its own page.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With