ValidityState.stepMismatch

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since December 2018.

stepMismatchValidityState オブジェクトの読み取り専用プロパティで、 <input> の値がユーザーに変更された後、その要素の step 属性に設定された制約に適合しないことを示します。

フィールドが数値の性質を持つ場合、例えば date, month, week, time, datetime-local, number, range の何れかの型であり、 step の値が any ではなく、値が stepmin の値に設定された制約に適合しない場合に、 stepMismatch が true になります。フォームコントロールの値から min の値を引き、 step 値 (省略時は既定で 1) がゼロでない場合、一致しないと言えます。

次のようになっていたとします。

html
<input type="number" min="20" max="40" step="2" />

(value - min) % 2 != 0 であれば、 stepMismatch は true になります。

true の場合、その要素は CSS の :invalid および :out-of-range 擬似クラスに一致します。

仕様書

Specification
HTML
# dom-validitystate-stepmismatch

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
stepMismatch

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報