HTML Forms: Confused with the required attribute. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HTML Forms: Confused with the required attribute.

<form method="post" action=""> <input type="text" required> <button type="submit">submit</button> </form> I have a code like this with method ="post". I'm confused about the required attribute. Which one is true in this code? 1. "Required" attribute will check if the text field is empty on the server side when the form is submitted. 2. "Required" attribute will check if the text field is empty on the client side when the form is submitted. 3. submit button can be clicked even if the text field is empty.

14th Oct 2022, 11:12 PM
Jojo
Jojo - avatar
2 Answers
+ 4
Number 2
15th Oct 2022, 1:47 AM
Arturop
Arturop - avatar
0
2. The "required" attribute demands a value in the input text field or in which input field he's applied to. If the input field stays empty on the client side the form will not be submitted. NO text (value) = NO submit
27th Oct 2022, 1:36 PM
Christian Daumal
Christian Daumal - avatar