jcadima
2/16/2016 - 3:46 PM

Validate Checkbox

Validate Checkbox



<form id="homeform" method="post" action="https://prestigepay.com/?page_id=208" onsubmit="return validateForm()">


</form>


function validateForm() {
    var fname  = document.forms["homeform"]["FirstName"].value;
	var lname  = document.forms["homeform"]["LastName"].value;
	var mobile = document.forms["homeform"]["MobilePhone"].value;
	var email  = document.forms["homeform"]["Email"].value;
	// this
	var checkedbox = document.getElementById('IsReceiveSms');
 //	 ... 
    if ( validatecheckbox(checkedbox) == false ) {
        sweetAlert("Oops!",  "Please check this box to continue so we can send you a verification code and important updates about your account.", "error");
        return false;
    }	
	
}	




// CHECKBOX 
function validatecheckbox(checkbox) {
	var result = true;
  if (checkbox.checked){
    result = true;
  }else{
    result = false;
  }
  return result ;
}