Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the inputmode attribute valid (in HTML5 forms) or not?

I am getting validation errors with the inputmode attribute on text areas and text fields. The validator tells me Attribute inputmode not allowed on element input at this point but the HTML5 spec indicates that it is allowed.

Is there actually something wrong with this code, or is the validator at fault?

Here is a bare bones case which will produce exactly this kind of validation error (twice), in one case on an email input, and on the other on a textarea.

<!DOCTYPE HTML>
<html lang="en">
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <form method="post" action="contactme.php">         
      <label class='pas block'>
        Your E-Mail:<br/>
        <input type='email' name='email' required inputmode='latin' placeholder='your e-mail here' />
      </label>
        <label class='pas block'>
                Your Message:<br/>
                <textarea name='message' required inputmode='latin' placeholder='and your message here!'></textarea>
        </label>
    </form>
  </body>
</html>
like image 947
brennanyoung Avatar asked Nov 07 '12 12:11

brennanyoung


People also ask

What is Inputmode in HTML?

The inputmode is an HTML Global attribute (Global attributes are common to all HTML elements) which helps browsers or devices with on-screen keyboards to help them decide which keyboard to display when a user has selected an area for some input or textarea element.

Which attribute is not used on new forms?

Which attribute is not used on new forms? 11. Which of the following is not used with password attribute? Explanation: password is the attribute that creates a text box which is similar to the single line text input, but the characters are blocked out.


3 Answers

Also, see the chart about which attributes apply to the different input types here: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#attr-input-type

The "inputmode" attribute applies only to "text" and "search".

UPDATE 2019-09-04: "inputmode" is now a global attribute (per WHATWG) and can be specified on any HTML element: https://html.spec.whatwg.org/multipage/dom.html#global-attributes

Another reference page for "inputmode": https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode

On another note, "inputmode" is not a W3C HTML5 attribute, but it is a W3C HTML 5.1 attribute (at least at the time I'm writing this). UPDATE 2019-09-04: "inputmode" has been removed from HTML 5.2 and HTML 5.3.

like image 66
Albert Wiersch Avatar answered Oct 24 '22 14:10

Albert Wiersch


The HTML5 spec says

The following content attributes must not be specified and do not apply to the element: accept, alt, checked, dirname, formaction, formenctype, formmethod, formnovalidate, formtarget, height, inputmode, max, min, src, step, and width.

It's under bookkeeping details at https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type=email)

like image 36
dsas Avatar answered Oct 24 '22 14:10

dsas


Five years after the question was asked, some may wonder why some of the properties listed by @dsas doesn't trigger such errors, like enctype The answer is simple support, while enctype for instance gained a wide support inputmethod is supported only as of IE11 and Edge 14, for more infos click here

like image 1
user10089632 Avatar answered Oct 24 '22 14:10

user10089632