hello, can u plz help me?? I can't run the javascript on Mozilla nad IE(can run on Chrome) I don't know why. I think my javascript has some problem. Here is my code .....

<script>
		function check()
		{
		if(document.getElementById("name").value==""||document.getElementById("address").value==""||document.getElementById("phone").value==""||document.getElementById("email").value==""||document.getElementById("username").value==""||document.getElementById("passwd").value==""||document.getElementById("passwd2").value==""){
		alert("You need to complete the form");
		}
		else continue;
		}
		
		function check_no()
		{
		var no=document.getElementById("phone").value;
		
		if(isNaN(no)==false){alert("right");}
		else {alert("Only number");}
		}
		
		function check_email(email,alerttxt)
			{
			with (email)
			  {
			  apos=value.indexOf("@");
			  dotpos=value.lastIndexOf(".com");
			  dotpos2=value.lastIndexOf(".net");
			  if (apos>1)
				{
				  if(dotpos-apos>1||dotpos2-apos>1){document.getElementById('email_error').style.visibility="hidden"; return true;}
				  else{document.getElementById('email_error').style.visibility="visible";}
				  }
			  else {document.getElementById('email_error').style.visibility="visible";}
			  }
			}
			
			function check_pass()
			{
			var first=document.getElementById("passwd").value;
			var second=document.getElementById("passwd2").value;
			if(first==second)continue;
			else {alert("Passwords do not match");document.getElementById("passwd").value="";document.getElementById("passwd2").value="";document.getElementById("passwd").select();}
			}
	</script>

Thz u for ur helps.

Dani AI

Generated

The symptoms you described (works in Chrome but fails in IE/Firefox) usually come from a syntax/runtime error or a DOM/timing problem rather than a browser “quirk.” was right to flag the stray continue usage — continue is only valid inside loops — but removing that may not be the only fix. The following checklist and example show how to find the real error and make the validation robust and cross-browser.

Open the browser console (F12) in the browsers that fail and look for the first error and line number. A SyntaxError will stop all script execution. See why continue is invalid here: MDN — continue. Also avoid with — it creates ambiguous scope and is deprecated: MDN — with.

Basic practical steps

  • Use the console error/line number to find the broken statement.
  • Run your script after the DOM is ready (or place the script before </body>). See DOMContentLoaded.
  • Stop form submission with return false (or event.preventDefault()), not continue.
  • Replace fragile checks (like searching for “.com”) with simple regexes and explicit comparisons. Use /^\d+$/ for digits rather than relying on isNaN for form strings.
  • Attach handlers in a cross-browser way: addEventListener with fallback for old IE. See addEventListener.

Example pattern (run after DOM ready): a submit handler that iterates required fields, checks digits, validates basic email pattern, and compares passwords. Use that pattern to isolate the failing step: comment out parts and re-run until the error disappears. Once the console shows no syntax/runtime errors, the behavior will be consistent across Chrome, Firefox and IE.

Recommended Answers

All 11 Replies

Member Avatar for Member #334542
function check()
		{
		if(document.getElementById("name").value==""
			||document.getElementById("address").value==""
			||document.getElementById("phone").value==""
			||document.getElementById("email").value==""
			||document.getElementById("username").value==""
			||document.getElementById("passwd").value==""
			||document.getElementById("passwd2").value==""){
			alert("You need to complete the form");
		}
		}

Remove elsepart with continue;

function check_pass()
			{
			var first=document.getElementById("passwd").value;
			var second=document.getElementById("passwd2").value;
			[B]if(!(first==second)){alert("Passwords do not match");document.getElementById("passwd").value="";document.getElementById("passwd2").value="";document.getElementById("passwd").select();} [/B]
			}

Make the changes in the function like above here to removed the continue.

It's still incorrect. :(

It's still incorrect. :(

Member Avatar for Member #120589

Did you think of posting this in the JS forum?

Actually I used it in HTML file ... to check validation...

Member Avatar for Member #120589

Actually I used it in HTML file ... to check validation...

Of course, but it's still a js issue. You may get more js experts in the js forum.

Thanks for sharing knowledge.

commented: You should die a horrible death for sig spamming -1
Member Avatar for Member #120589

Thai spy with my little eye a spammer beginning with servertoday. Shameless. Go clog up another site.

Thz u all I'll move this to JS forum ....

hi, i need help concerning js is there anybody that can help?

Member Avatar for Member #120589

>hi, i need help concerning js is there anybody that can help?

Go - to - the - JS - forum...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.