-1

For some reason my JavaScript won't validate my forms and I cannot work out why. I've followed examples from many sites like Tizag & W3C, but to no avail.

HTML form:

<form class='login' name='login' onsubmit='return loginValidation();' method='post' action='index.php'>
    <p>
       <input class='login' type='text' name='nameentry'/><br/>
       <input class='login' type='submit' value='Login'/>
    </p>

</form>

JavaScript function:

    function loginValidation(){
    var x=document.form.login.nameentry.value;
    if(x==null || x==""){
        alert("Enter a name");
        return false;
    }
}

My code can be seen in action here [an assignment]. Any ideas?

2 Answers 2

2

You have an unclosed function (or for block) which is killing the engine:

function testAllQuantity(){
    for(i=0;i<150,i++){
      quantityValidation(document.getElementById(i));
    }

And the for statement is misformed, , -> ;

for(i=0;i<150;i++){
Sign up to request clarification or add additional context in comments.

2 Comments

Those validation functions were works in progress, never considered that they could be the problem as I assumed it would only use the one in question, thanks!
Cheers for the advice with that loop too :)
2

Second line in function should be

var x=document.forms.login.nameentry.value;

1 Comment

I've changed it & the results are no different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.