html - getting a message to be displayed on javascript method -
firstly show code. html:
<label>password </label> <input type="password" id="pword"><br> <label>confirm password </label> <input type="password" id="confpword" onkeyup="passwordvalidation(); return false;"> <span id="themessage" class="themessage"></span><br>
js:
function passwordvalidation(){ var username = document.getelementbyid("uname"); var password1 = document.getelementbyid("pword"); var confpword1 = document.getelementbyid("confpword"); var themsg = document.getelementbyid("themessage"); var gc = "#ff6666"; if (password1.value == confpword1.value){ themsg.style.color = gc; themsg.innerhtml = "passwords match"; }else{ themsg.style.color = gc; themsg.innerhtml = "passwords not match"; } }
i cant work out why nothing show after start typing stuff input boxes. after have 'keyed up' once typing confirm password box surely 1 of 2 messages should display. cant work out why text not visible.
js fiddle show problem current code. people can edit if helps
thanks
your code works, jsfiddle setup wrong.
you need put javascript code execution option "no wrap - in head" or "no wrap - in body" if want call functions one.
ondomready not keep function.
Comments
Post a Comment