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

https://jsfiddle.net/z5xj4hrt/

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.

see corrected jsfiddle


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -