javascript validation of html form element for non-blank

I read a javascript book and now I am trying to apply it.
Here I simply want to force entry of something on a form text box.  I had high hopes, but I can tab right through the form.

Here is the html:

<td>Enter Userid</td><td><input type="text" name="userid" size="15" maxlength="15" onblur="MustEnter(this)"></td></tr><tr>
<td>Select Password</td><td><input type="password" name="password" size="15" maxlength="15" onblur="MustEnter(this)"></td></tr><tr>
<td>City of Birth</td><td><input type="text" name="cityofbirth" size="15" maxlength="15" onblur="MustEnter(this)"></td></tr><tr>
<td>Favorite color</td><td><input type="text" name="mothersmaidenname" size="15" maxlength="15" onblur="MustEnter(this)"></td></tr>
<tr><td>First name</td><td><input type="text" name="firstname" size="20" maxlength="20" onblur="MustEnter(this)"></td></tr>
<tr><td>Last name</td><td><input type="text" name="lastname" size="30" maxlength="30" onblur="MustEnter(this)"></td></tr>
<tr><td>Email</td><td><input type="text" name="email" size="40" maxlength="50" onblur="MustEnter(this)"></td></tr>

Here is the javascript from a js file that is loaded and working on another function:

function MustEnter(oTextbox) {
      if oTextbox.value.length==0 {
            alert("Must enter");
            return false;
      return true;

I would rather know what is wrong with this, then have a signifcantly different solution I do not understand.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


if oTextbox.value.length==0
if (oTextbox.value.length==0)

By Nab

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
astar666Author Commented:
that helps.  I now get the alert.  However the cursor advances to the next text box.  Please advise.

onblur is called whenever focus is transfered to other textbox i.e. cursor advences to other text box.
May be this can cause an infinite loop. So its not suggested that you use onblur. Try using onkeyup instead of onblur. Or use a <form onsubmit="return validate()" > to "validate" at submission of form.

By Nab

astar666Author Commented:
onkeyup did not work, but advanced the cursor
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.