Content-Length: 203578 | pFad | http://developer.mozilla.org/ja/docs/Web/API/HTMLInputElement/maxLength

HTMLInputElement: maxLength プロパティ - Web API | MDN

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

HTMLInputElement: maxLength プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

maxLengthHTMLInputElement インターフェイスのプロパティで、この <input> 要素の値として入力が許可される最大文字数(UTF-16 コード単位)と、有効な値として許可される最大文字数を示します。これは、この要素の maxlength 属性を反映します。-1 は、値の長さに制限がないことを意味します。

メモ: ブラウザーは通常、maxlength 属性で許可された文字数以上の文字が入力できないようにしています。長さがこれより長い場合、その要素は無効と見なされ、ValidityState オブジェクトの tooLong プロパティが true になります。

存在する場合は要素の maxlength を表す数値、さもなくば -1

次の HTML があったとします。

html
<p>
  <label for="password">パスワード</label>
  <input id="password" type="password" minlength="8" maxlength="20" />
</p>

maxLength プロパティを使用して、<input>maxlength 属性値を取得または設定することができます。

js
const inputElement = document.querySelector("#password");
console.log(`要素の maxLength: ${inputElement.maxLength}`); // "要素の maxlength: 20"
inputElement.maxLength = 18; // この要素の maxlength 属性値を更新

仕様書

Specification
HTML
# dom-input-maxlength

ブラウザーの互換性

関連情報









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://developer.mozilla.org/ja/docs/Web/API/HTMLInputElement/maxLength

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy