How does the form validation work on angularjs with ionic?

Checkbox Validation not working?

  • Hello all. I am attempting to create a form with multiple validations. I have validations currently for First name and Email here: <script type="text/javascript"> function validateForm() { var x=document.forms["schedule"]["firstname"… if (x==null || x=="") { alert("First name must be filled out"); return false; } var x=document.forms["schedule"]["email"].va… var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { alert("Not a valid e-mail address"); return false; } } </script> Those validations work, however when I try to add a validation for a checkbox "terms of agreement" the validation doesnt seem to work. For checkbox validation I add: if(!document.schedule.agree.checked) { alert("Please check the terms and conditions"); return false; } I am adding this to the end of the current validation. I understand that by adding an if statement after the "email if statement " I am only adding to those if statements, but how would i avoid this error?

  • Answer:

    I'm guessing you inherited this code? The checkbox is trivial compared to the other stuff. I am not comfortable with the use of... document.schedule.agree.checked I would prefer... document.getElementById('agree').checked ...where an id="agree" has been added to the checkbox.

David at Yahoo! Answers Visit the source

Was this solution helpful to you?

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.