Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML 5 input check: the validation message appears only by repeated calling
    primarykey
    data
    text
    <p>I have a form including two password fields (password, password confirmation). I need their issues about different values to look like a standard HTML-5 pop-up message (see the illustration pls). <img src="https://i.stack.imgur.com/aKcfd.gif" alt="enter image description here"> For this purpose I have attached the html5/JS function setCustomValidity() to the password2 field. Form.submin() triggers that checking. But the problem is that if values are different the message appears only starting from attempt #2. I.e. initial event does nothing - form doesn't send data but the message doesn't appears also. If I repeat this it appears. I have no any appropriate ideas why. Do you? Here is the full inner code:</p> <pre><code>&lt;script&gt; function validateForm(){ var pass1=document.getElementById('password1'); var pass2=document.getElementById('password2'); var pass1Val=pass1.value; var pass2Val=pass2.value; if(pass1Val&amp;&amp;pass2Val&amp;&amp;(pass1Val!=pass2Val)){ pass2.setCustomValidity("The password confirmation is different to the password value"); return false; } } &lt;/script&gt; &lt;form id="user-form" action="#" method="post" enctype="text/plain" onSubmit="return validateForm();"&gt; Email: &lt;input type="email" id="emailField" required="required"&gt; &lt;br&gt; Tel: &lt;input type="tel" id="phoneField" required="required"&gt; &lt;br&gt; Password: &lt;input type="password" id="password1" required="required"&gt; &lt;br&gt; Password2: &lt;input type="password" id="password2" required="required"&gt;&lt;br&gt; &lt;input type="submit" value="Send!"&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload