Javascript Form Validation doesn't work on FireFox browsers. Why?
-
I have a javascript function that checks to make sure all the required fields on my form are completed. Of a field is not complete, there is a pop-up that tells the user which field they missed. The function works like a charm on Internet Explorer. If I use firefox and skip one of the required fields, I still get the pop-up, but the script moves forward anyway, without the required data. What is wrong? <script type="text/javascript"> <!-- function validate_form() { valid = true; if ( ( document.frm.systemtype[0].checked == false ) && ( document.frm.systemtype[1].checked == false ) && (document.frm.systemtype[2].checked == false ) ) { alert ( "Please select the type of system you are interested in replacing." ); valid = false; } if ( ( document.frm.fur_type.selectedIndex == 0 ) && ( document.frm.fur_type.disabled == false ) ) { alert ( "Please select your fuel type." ); frm.fur_type.focus(); valid = false; } if ( document.frm.zip.value == "" ) { alert ( "Please fill in the 'Zip Code' box." ); frm.zip.focus(); valid = false; } return valid; } //--> </script>
-
Answer:
<script type="text/javascript"> <!-- function validate_form() { valid = true; for(var i = 0; i < document.frm.systemtype.length; i = i + 1){ if ( document.frm.systemtype[i].checked == false) { valid = false; alert ( "Please select the type of system you are interested in replacing." ); } } if ( ( document.frm.fur_type.selectedIndex == 0 ) && ( document.frm.fur_type.disabled == false ) ) { valid = false; alert ( "Please select your fuel type." ); frm.fur_type.focus(); } if ( document.frm.zip.value.length < 5 ) { valid = false; alert ( "Please fill in the 'Zip Code' box." ); frm.zip.focus(); } return valid; } //--> </script> Try this
michaeln... at Yahoo! Answers Visit the source
Other answers
Change true and false to True and False
Related Q & A:
- How come CD doesn't work in my shell script?Best solution by Super User
- Youtube doesn't work on iphone?Best solution by answers.yahoo.com
- Google doesn't work (google.com) on any computer?Best solution by Yahoo! Answers
- Yahoo Music Doesn't Work?Best solution by Yahoo! Answers
- Mail search doesn't work?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.