java script not supported in my mozilla browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramanagosu
    New Member
    • Mar 2009
    • 9

    #1

    java script not supported in my mozilla browser

    HI everybody
    I am writing java script code it's working fine in IE browser and not working fine in Mozilla
    code:
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    	function verify() {
    		var themessage = "You are required to complete the following fields: ";
    		if (document.form.title.value=="") {
    		themessage = themessage + " - Class Title";
    		}
    		//alert if fields are empty and cancel form submit
    		if (themessage == "You are required to complete the following fields: ") {
    			document.form.submit();
    		} else {
    			alert(themessage);
    			event.returnValue=false;
    		}
    	}
    </script>
    
    <form enctype="multipart/form-data" method="post"  name="form" onSubmit="verify()" action="admin_addclass2.php">
    
    
    //fields here
    </form>
    what is wrong with that it gives alert message in mozilla but post next page when we click ok in alart box (actually when we click OK in alert box it display same page )

    please send me any suggestion with that.

    Cheers

    ramana
    Last edited by numberwhun; Mar 7 '09, 05:27 AM. Reason: Please use code tags!!!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    could be a name confusion. there is a universal attribute called "title" in HTML, which you can access via html_element.title, thus making document.form.t itle.value point to <form title="" ...> (which is empty) ...

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Try the following changes:
      Code:
      		if (themessage == "You are required to complete the following fields: ") {
      			return true;
      		} else {
      			alert(themessage);
      			return false;
      		}
      and
      Code:
      <form enctype="multipart/form-data" method="post"
        name="form" 
      [b]onSubmit="return verify()"[/b]...

      Comment

      Working...