javascript onsubmit() NOT working as expected
<pre><code>    function trim(str) {
         str.replace(/^\s*/, '').replace(/\s*$/, '');
         return str;
     }

   function checknull(str) {
         if (str==null || str==""||isNaN(str)){
        valid=false
        alert("Field must be a number and can not be NULL");
        return valid;
        }
       else
    {
    return true;
    }
}


function checkform(){
valid = true;
var input1=document.form1.TASKID.value;
checknull(trim(input1));
var x=document.main_form.iid.value;
checknull(trim(x));

return valid;
}
</code></pre>

<p>The above Javascript is NOT working as expected. Whenever, Input is NON-number, alert box is coming, however it continues to do ACTION command. Don't know why.Below is HTML code thats using this Javascript.</p>

<pre><code>&lt;form method="POST" name="form1" action="myaction.cgi" onSubmit="return checkform()"&gt;
</code></pre>

<p>it is checking only one element at a time, when I use second form, the validation is happening fine, when I use firstform(form1) the validation is happening, however, the form continues to execute its action. WHY? am confused. please help</p>
