#Help with creating a form, specifically how to confirm password
16 messages · Page 1 of 1 (latest)
once the button is clicked
Where is the code checking for a button click or form submit?
<body>
<h1>Form</h1>
<form name="myform" onsubmit="showResult(event)">
<label for="id_fullname">Full name</label>
<input
type="text"
id="id_fullname"
name="fullname"
size="40"
autofocus required placeholder="FirstName LastName"
>
<br>
<label for="id_password">Password</label>
<input type="password" id="id_password" size="40" name="password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" required/>
<br>
<label for="id_passwordr">Password repeated</label>
<input type="password" id="id_passwordr" size="40" name="passwordr" required/>
<br>
<fieldset>
<legend>gender</legend>
<input type="radio" name="gender" value="male" id="male" />
<label for="male">male</label>
<input type="radio" name="gender" value="female" id="female" />
<label for="female" >female</label > <label for="other">
<input type="radio" name="gender" value="other" id="other" />other</label>
</fieldset>
<br> ```
1/2 rest of code
Never have on* in HTML but anyway. This doesn't seem to call validatePassword
2/2 rest of code
And your passwordPattern variable doesn't seem to be used
Form submission without preventDefault
<input type="range" name="height" id="id_height" min="25" max="300" step="1"
oninput="id_height2.value = this.value" value="175">
<input type="number" id="id_height2" min="25" max="300"
step="1" oninput="id_height.value=this.value">
<br>
<label for="id_country">Country:</label>
<select name="country" id="id_country">
<option value="fi" selected>Finland</option>
<option value="es">Estonia</option>
<option value="sv">Sweden</option>
<option value="no">Norway</option>
<optgroup label="Baltic">
<option value="es" >Estonia</option>
<option value="lv">Latvia</option>
<option value="lt">Lithuania</option>
</optgroup>
</select>
<br>///this is the button
<input type="submit" value="Send" >
<hr>
<output id="id_result"></output>
</form>
</body>````
the button is there ^
okkay
i used the passwordPattern variable by adding this js password.pattern = passwordPattern.source; but the regex still doesnt work
still claims that im not meeting requirements
nvm i think it maybe works
but i do must say that i dont think i know how to call validatePassword properly
you're using a ton of bad/old practices. see #faq to learn modern JS. also: https://phoenix35.js.org/good-practices.html#correct-use-of-js-in-the-browser
haven't actually seen setCustomValidity() before. it appears you're missing reportValidity(), though. https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity