Home > DeveloperSection > Forums > Form gets submiited twice on button click
john rob

Total Post:108

Points:756
Posted on    May-02-2013 3:30 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 791  View(s)
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! 



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-02-2013 8:23 AM

Hi John!

Use any one that is in else condition.

Use either:

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

return true;

Don't want to miss updates? Please click the below button!

Follow MindStick