wonderful world
wonderful world

Reputation: 11599

HTML5 required attribute

I have the following input element in a form. When the form is submitted, I don't need a value for this field. However, when I click the submit button for the form, it gives me an error saying 'This is a required field'.

<input required="false"/>

Upvotes: 1

Views: 112

Answers (2)

zessx
zessx

Reputation: 68820

Using required means you need a value for this field.

If this value is optional, you must not use required.

As a side note, this is the HTML5 syntax (no value for properties, and no ending slash for autoclose tags) :

<input required>

Upvotes: 2

Pogrindis
Pogrindis

Reputation: 8131

Simple remove the required tag from it completely.

Required should only be added to the html input when it IS required.

Also you do not need to specify true | false on this.

Reference

Upvotes: 1

Related Questions