How does the form validation work on angularjs with ionic?

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

Was this solution helpful to you?

Other answers

Change true and false to True and False

Related Q & A:

Just Added Q & A:

Find solution

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.