FORM GETS SUBMIITED TWICE ON BUTTON CLICK

john rob

Total Post:108

Points:756
Posted by  john rob
 1039  View(s)
Ratings:
Rate this:
Hi Mindstickians!

I have called below javascript function on

function formOnSubmit() {
    if (document.forms[0].ref_no.value == "") {

        if (document.forms[0].acc_code.value == "") {

            if (document.forms[0].vendor_code.value == "") {

                if (document.forms[0].acc_service_tax.value == "") {

                    if (document.forms[0].acc_doc_name.value == "") {
                        alert('Please enter atleast one attribute value');
                        return false;
                    }
                }
            }

        }
    } else {
        return true;
        document.forms[0].submit();

    }
}
where, ref_no,acc_code,vendor_code,acc_service_tax,acc_doc_name are textboxes

The problem is form gets submitted twice when I enter something in ref_no texbox and form submitss once for the rest of textboxes.

I want to know why form gets submitted twice when I enter ref_no value.

Thanks in advance! 

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Form gets submiited twice on button click

    Hi John!

    Use any one that is in else condition.

    Use either:

    document.forms[0].submit();
    else

    return true;

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!