javascript - getting html and jscript to validate a password? -
just quick question im unsure why not working
html:
<label>password </label> <input type="password" id="pword"><br> <label>confirm password </label> <input type="password" id="confpword"><br>
js:
function passwordvalidation(){ var username = document.getelementbyid("unamem"); var password1 = document.getelementbyid("pword"); var confpword1 = document.getelementbyid("confpword"); if (password1 != confpword1){ window.alert("passwords don't match") }else{ window.alert("well done match") } }
surely code should work? whatever type in, never hits else block. ideas?
thanks
change if
if (password1.value != confpword1.value){ window.alert("passwords don't match") }
Comments
Post a Comment