Form Validation in React js
According MDN, form is an "element represents a document section containing interactive controls for submitting information." In short, it allows users to submit information.
Form action and method
Let's go over method first. You will usually see two different form methods: GET and POST. A GET performs a GET HTTP method. If you want to code along, just create an html file and copy the path in your browser
Btw, if we have ""
(blank) action, we are telling our form to perform the HTTP request to the same URL. If I enter "test"
as username and press submit, note that the URL changes to: form.html?user_name=test
Doing GET request on HTML form will pass user input into query params.
When we do POST request, it will perform POST HTTP request to the page you define inside "action"
. Since we have "" as action, it will do POST HTTP request into this page.