I want to print out a series of error messages on my html page based on what the user enters such as password, user name, address etc., which the information failed to validate.
My code looks like this:
function validate(){ var x,y,z; x = document.getElementById("name").value; if (x.length<6){ text="user name too short"; } else { text="validated"; } document.getElementById("aka").innerHTML = text; } Now I can only validate one input. In this case the input with id "name".
I want to validate all the inputs like password also in this function.
How could I implement that in the function?
I tried adding more if statement followed by another document.getElementById("aka").innerHTML = text, but didnt work and the first didn't print out.