I am trying to check if the name text field is empty. if it is, then i want to show a div that says "please enter your name". i do a test, and name='name'. but after that, nothing else pops up.
function validate(input, name) {
if(name=='name') {
if(input==null || input=="") {
name.style.visibility='visible';
alert("please enter a value");
} else {
alert("valid entry.");
}
}
}
when I print out input with the alert box, it does not contain anything; so I know that it is either null or "". how do i fix this so that it works?
here is my text field:
<input type="text" name="name" id="name" onblur="javascript: validate(this.value, this.id);" required />
<div id="name" style="visibility:hidden; float:right;">Please fill in a name!</div>
nameis being assigned. And then show us a representative demo; we're looking for SSCCE (Short, Self-Contained, Correct/Compilable Example).