I have prepared two input tags for the password.If the value entered in the first input tag does not match the value of the second confirmation input tag when submit is pressed, I would like to write a code that says "Mismatch" in the alert.
HTML
<tr>
<th>Password </th>
<td><input type="password" th:text="${loginPass1}">/td>
</tr>
<tr>
<th>Password Confirmation</th>
<td><input type="password" th:text="${loginPass2}">/td>
</tr>
JavaScript
var loginPass1 = 'loginPass';
var loginPass2 = 'loginPass';
//
if(loginPass1!==loginPass2){
alert('Passwords do not match');
}
Perhaps you can do this.
function passwordCheckFunction(){
var loginPass1 = document.getElementById("loginPass1").value;
var loginPass2 = document.getElementById("loginPass2").value;
if(loginPass1!==loginPass2){
alert("Passwords do not match.")
}
}
<tr>
<th>Password </th>
<td><input type="password" id="loginPass1" th:text="${loginPass1}">/td>
</tr>
<tr>
<th>Password Confirmation</th>
<td><input type="password" id="loginPass2" th:text="${loginPass2}">/td>
</tr>
<button type="button"class="passwordCheck"onclick="passwordCheckFunction()">Click Me!</button>
© 2024 OneMinuteCode. All rights reserved.