I have a basic question. I cannot find an explanation of form action="." despite searching for on google, www.w3schools.com, etc...
Anyone know what the . action means for forms? Is it specific to Django? Bootstrap?
Code below:
{% extends "Blog.html" %}
{% block blog%}
<h1>Create an account</h1>
<p>Please, sign up using the following form:</p>
<form action="." method="post">
{{ user_form.as_p }}
{% csrf_token %}
<p><input type="submit" value="Create my account"></p>
</form>
{% endblock %}
Definition and Usage. The formaction attribute specifies the URL of the file that will process the input control when the form is submitted. The formaction attribute overrides the action attribute of the <form> element.
The HTML form action attribute defines what should happen to data when a form is submitted on a web page. The value of the action attribute should be the URL of the web resource that will process the contents of the form.
The HTML | action Attribute is used to specify where the formdata is to be sent to the server after submission of the form. It can be used in the <form> element. Attribute Values: URL: It is used to specify the URL of the document where the data to be sent after the submission of the form.
An HTML form is used to collect user input. The user input is most often sent to a server for processing.
Form Action attribute specifies where to send the form-data when a form is submitted
Possible accepted values:
in your case of action="."
you are pointing to current url/file/directory.
So it will reload the same page on form submission.
Normally, the action
attribute in a form specifies where the data should go to, for example a processing file: action="proces.php"
.
Sometimes, action="#"
or action="."
is used to reload the page and process the data on the same page.
Basically, it just submits the form to the same page.
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