This script works fine as long as var usename has some value. I’m trying to create an alert which will tell the viewer (after they call this function) that they need to enter a name if they leave the name field blank in the form. (The form is called fname.). I tried using if(usename==null) and that didn’t work either. Any ideas? Thanks.
<script language=”javascript”>
function printname()
{
var usename=document.fname.username.value;
if (usename==” “)
{
window.alert(“We needs a name”);
}
else
{
document.getElementById(‘namediv’).innerHTML=(usename+”, I’m very excited for you. Please answer all the questions honestly, because we know when you’re lying.”);
document.getElementById(‘namediv’).style.display=”block”;
}
}
</script>