Help us understand the problem. What is going on with this article?

setCustomValidity

More than 5 years have passed since last update.
<form>
  <p><label>パスワード <input type=password name=password required pattern="[!-~]{5,}" title="英数字5文字以上"></label>
  <p><label>もういちど <input type=password name=password2 required pattern="[!-~]{5,}" title="英数字5文字以上"
                           oninput=" this.setCustomValidity(this.form.elements.password.value === this.value ? '' : this.getAttribute('data-password-mismatch-error')) "
                           data-password-mismatch-error="同じパスワードを記入してください。"></label>
  <p><button type=submit>設定</button>
</form>

setCustomValidity で独自のバリデーションエラーメッセージを設定することができます。エラー状態ではフォームを提出できず、ユーザーにエラーメッセージが表示されます。空文字列を指定するとエラー状態を解除できます。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした