HTML form AttributeHTMLIn HTML there are various attributes available for HTML enctype attributeThe HTML enctype attribute defines the encoding type of form-content while submitting the form to the server. The possible values of enctype can be:
Example:
Example:
Example:HTML novalidate attribute HTML5The novalidate attribute is newly added Boolean attribute of HTML5. If we apply this attribute in form then it does not perform any type of validation and submit the form. Example:Output: Fill the formEnter age: Enter email: Try to change the form detials with novalidate atttribute and without novalidate attribute and see the difference. HTML element attributeHTML name attributeThe HTML name attribute defines the name of an input element. The name and value attribute are included in HTTP request when we submit the form. Note: One should not omit the name attribute as when we submit the form the HTTP request includes both name-value pair and if name is not available it will not process that input field.Example:Output: Fill the formEnter age: Enter email: Note: If you will not use name attribute in any input field, then that input field will not be submitted, when submit the form. Click on submit and see the URL where email is not included in HTTP request as we have not used name attribute in the email input field HTML value attributeThe HTML value attribute defines the initial value or default value of an input field. Example:Output: Fill the formNote: In password input filed the value attribute will always unclear HTML required attribute HTML5HTML required is a Boolean attribute which specifies that user must fill that filed before submitting the form. Example:Output: Fill the formIf you will try to submit the form without completing email field then it will give an error pop up. HTML autofocus attribute HTML5The autofocus is a Boolean attribute which enables a field automatically focused when a webpage loads. Example:HTML placeholder attribute HTML5The placeholder attribute specifies a text within an input field which informs the user about the expected input of that filed. The placeholder attribute can be used with text, password, email, and URL values. When the user enters the value, the placeholder will be automatically removed. Example:Output: Registration formHTML disabled attributeThe HTML disabled attribute when applied then it disable that input field. The disabled field does not allow the user to interact with that field. The disabled input filed does not receive click events, and these input value will not be sent to the server when submitting the form. Example:Output: Registration formHTML size attributeThe size attribute controls the size of the input field in typed characters. Example:Output: Registration form with disbaled attributeHTML form attributeHTML form attribute allows a user to specify an input filed outside the form but remains the part of the parent form. Example:Output: User password: The email field is outside the form but still it will remain part of the form User email: Next TopicHTML with CSS
|