[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/API/HTMLTextAreaElement/setCustomValidity [Back]  [Original]

HTMLTextAreaElement: setCustomValidity() - Web API | MDN

MDN Web Docs

View in English Always switch to English

HTMLTextAreaElement: setCustomValidity()

Baseline

20157

setCustomValidity() HTMLTextAreaElement <textarea>

js
setCustomValidity(string)

string

(undefined)

<textarea>

js
const comment = document.getElementById("comment");
if (comment.validity.valueMissing) {
  comment.setCustomValidity("");
} else if (comment.validity.tooShort) {
  comment.setCustomValidity("");
} else if (comment.validity.tooLong) {
  comment.setCustomValidity(
    " 800 ",
  );
} else {
  comment.setCustomValidity("");
}

HTML
# dom-cva-setcustomvalidity-dev


Web Proxy Viewer  |  New URL  |  Original Page