HTML5 Valid Form Input/Fields

10,591

Solution 1

type="input" is an invalid value of the attribute type of the input element.

This guide on the input element shows the allowed type attributes. Or check the HTML5 additional input types if you require one of those.

For a regular textfield you need to set the type attribute to type="text".

Solution 2

Input type "input" is not correct, you probably intented to use type="text".

Share:
10,591
no.
Author by

no.

Updated on June 15, 2022

Comments

  • no.
    no. almost 2 years

    I'm a little confused as to what is considered valid markup for HTML5 input fields.

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Site Name</title>
    </head>
    
    <body>
    
        <form name="contact" method="post" action="/">
           <p><input type="input" name="first_name" maxlength="255" /></p>
        </form>
    
    </body>
    
    </html>
    

    When I run this through the validator at w3.org I get the error Bad value input for attribute type on element input. with the /> highlighted in red. I look at the HTML-Tidy version it creates and it tells me to write it like this instead:

    <p><input type="input" name="first_name" maxlength="255"></p>
    

    But then when I validate that I then get the same error but with just the > highlighted in red. Then looking at the HTML-Tidy to see what it has corrected it to and it leaves is the same as if it's okay, but the error is still there. Is this considered valid HTML5 markup? Or is there a specific way of doing this?