By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,029 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,029 IT Pros & Developers. It's quick & easy.

java script not supported in my mozilla browser

P: 9
HI everybody
I am writing java script code it's working fine in IE browser and not working fine in Mozilla
code:
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JavaScript">
  2.     function verify() {
  3.         var themessage = "You are required to complete the following fields: ";
  4.         if (document.form.title.value=="") {
  5.         themessage = themessage + " - Class Title";
  6.         }
  7.         //alert if fields are empty and cancel form submit
  8.         if (themessage == "You are required to complete the following fields: ") {
  9.             document.form.submit();
  10.         } else {
  11.             alert(themessage);
  12.             event.returnValue=false;
  13.         }
  14.     }
  15. </script>
  16.  
  17. <form enctype="multipart/form-data" method="post"  name="form" onSubmit="verify()" action="admin_addclass2.php">
  18.  
  19.  
  20. //fields here
  21. </form>
  22.  
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
Mar 7 '09 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
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.title.value point to <form title="" ...> (which is empty) ...
Mar 7 '09 #2

acoder
Expert Mod 15k+
P: 16,027
Try the following changes:
Expand|Select|Wrap|Line Numbers
  1.         if (themessage == "You are required to complete the following fields: ") {
  2.             return true;
  3.         } else {
  4.             alert(themessage);
  5.             return false;
  6.         }
and
Expand|Select|Wrap|Line Numbers
  1. <form enctype="multipart/form-data" method="post"
  2.   name="form" 
  3. onSubmit="return verify()"...
Mar 7 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.