Compare the password/confirm-password input values on their change
event and setCustomValidity accordingly:
function onChange() {_x000D_
const password = document.querySelector('input[name=password]');_x000D_
const confirm = document.querySelector('input[name=confirm]');_x000D_
if (confirm.value === password.value) {_x000D_
confirm.setCustomValidity('');_x000D_
} else {_x000D_
confirm.setCustomValidity('Passwords do not match');_x000D_
}_x000D_
}
_x000D_
<form>_x000D_
<label>Password: <input name="password" type="password" onChange="onChange()" /> </label><br />_x000D_
<label>Confirm : <input name="confirm" type="password" onChange="onChange()" /> </label><br />_x000D_
<input type="submit" />_x000D_
</form>
_x000D_