Javascript not working in firefox

Posted by Samuel Meddows on Stack Overflow See other posts from Stack Overflow or by Samuel Meddows
Published on 2011-02-06T14:58:04Z Indexed on 2011/02/06 15:25 UTC
Read the original article Hit count: 240

Filed under:
|

Hi guys,

I have a PHP form validation function that I developed in chrome and now will not work in firefox or Opera.

The function checks to see if a section of the form is blank and shows and error message. If there is no error then then the form submits through document.events.submit();

CODE:

function submit_events()
        {

            //Check to see if a number is entered if the corosponding textbox is checked
            if (document.events.dj_card.checked == true && dj_amount.value==""){

                //Error Control Method
                //alert ('You didn\'t enetr an Amount for DJ\'s Card!');
                var txt=document.getElementById("error")
                txt.innerHTML="<p><font color=\"#FF0000\"> You didn\'t enetr an Amount for DJ\'s Card!</font></p>";                 
            window.document.getElementById("dj_card_label").style.color = '#FF0000';

            //Reset
            window.document.getElementById("company_amount_label").style.color = '#000000';
            window.document.getElementById("own_amount_label").style.color = '#000000';


            }else{

                document.events.submit();

            }

The document.events.submit();does work across all my browsers however the check statements do not.

If the box is not ticked the form submits. If the box is ticked it does not matter whether there is data in the dj_amount.value or not. The form will not submit and no error messages are displayed.

Thanks guys.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about firefox