3. Form Attributes
Like all HTML elements that we have learned during the first and second quarter, form tags also have attributes. Here are some attributes that we can use in class:
● autocomplete – used to complete values in input boxes based on values that the user has typed in previous sessions on the same browser. As long as the user did not clear out the history records of the browser, the autocomplete feature will have values to refer to.
● disabled – is an attribute that does not take any value. By adding this attribute, you can inhibit the user from typing into the form element where it is placed until a condition is met.
One tip when you want to disable multiple form elements, add this attribute to the field set containing them. By adding the disabled attribute to the field set, you can disable all form elements in one go instead of typing disabled on each individual form element.
● novalidate – is used to tell the browser that it should not check the correctness of inputted values in the form. Browsers have their own input checker and will alert the user if the input is incorrect, even if the programmer did not add any script for checking. One example is if the page has a <input type=“number”> and the user attempts to type in a letter, the browser will tell the user that it is an invalid entry. The novalidate attribute overrides this feature of browsers. This is especially helpful when we are adding a save feature to website forms so that users can continue filling up the form at a later session.
● name – used to add a name to the form. This works like an id and a class name.
● target – used to define where the user inputs will be displayed after the form is submitted. This works like the target attribute for links.
There are other form attributes available such as action, method, and enctype but these attributes are used when processing the forms on the server-side. This is not covered in Computer Science 3 but you may read more on it if you are interested.