That is just not valid javascipt syntax!
$('#password1').checkPassword(){
...
}
It looks like a combination of calling a method (.checkPassword()
) and defining a new function.
Looking at your html, it looks like you are trying to call this function checkPassword
whenever the text changes in either password field:
<input class="form-text" id="password1" ... onchange="checkPassword()" ...>
When using jQuery, you should avoid specifying the function inline, instead attach it using jQuery .on
method
ns.init = function(){
$('#password1, #password2').on('change',function(){
var password1 = $('#password1').val()
console.log(password1);
var password2 = $('#password2').val()
console.log(password2);
if(password1==password2){
$("#reset-password").removeAttr("style");
}else{
$("#alert-error").removeAttr("style");
}
});
}
(Note: no need to repeat the code twice, that code above attaches the same behaviour to both password1
and password2
.)
You can also now remove that attribute from your html:
<input class="form-text" id="password1" name="password.password1"
type="password" maxlength="128" size="60"
placeholder="@Messages("securesocial.passwordChange.newPassword1")">