function validateEmailTo() {
  var emailRegex = /\b\w+@[\w.]+\.[A-z.]{2,4}\b/i;
  var emailErrors = 0;


  $('.email-to').val($('.email-to').val().replace(/\s+/g, '').replace(';', ','));
  $.each($('.email-to').val().split(','), function countErrors(index, value) {
    if (!emailRegex.test(value)) {
      emailErrors++;
    }
  });

  if (emailErrors === 0) {
    // cleared the check
    turnEmailErrorOff();
  } else if (isPanelEmpty($('.email-to'))) {
    // so... it didn't clear the check, but email is off so just remove bad email address and call it good
    turnEmailErrorOff();
  } else {
    // failed the check
    turnEmailErrorOn();
  }
}
// vaildate one or more email addresses if email is turned on
vaildate one or more email addresses if email is turned on
vaildate one or more email addresses if email is turned on
function validateEmailTo() {
  var emailRegex = /\b\w+@[\w.]+\.[A-z.]{2,4}\b/i;
  var emailErrors = 0;
  $('.email-to').val($('.email-to').val().replace(/\s+/g, '').replace(';', ','));
  $.each($('.email-to').val().split(','), function countErrors(index, value) {
    if (!emailRegex.test(value)) {
      emailErrors++;
    }
  });
  if (emailErrors === 0) {
    turnEmailErrorOff();
  } else if (isPanelEmpty($('.email-to'))) {
    turnEmailErrorOff();
  } else {
    turnEmailErrorOn();
  }
}
function validateEmailTo ( ) { var emailRegex = / \b\w+@[\w.]+\.[A-z.]{2,4}\b / i ; var emailErrors = 0 ; $ ( '.email-to' ) . val ( $ ( '.email-to' ) . val ( ) . replace ( / \s+ / g , '' ) . replace ( ';' , ',' ) ) ; $ . each ( $ ( '.email-to' ) . val ( ) . split ( ',' ) , function countErrors ( index , value ) { if ( ! emailRegex . test ( value ) ) { emailErrors ++ ; } } ) ; if ( emailErrors === 0 ) { turnEmailErrorOff ( ) ; } else if ( isPanelEmpty ( $ ( '.email-to' ) ) ) { turnEmailErrorOff ( ) ; } else { turnEmailErrorOn ( ) ; } }
vaildate one or more email addresses if email is turned on
vaildate one or more email addresses if email is turned on
// cleared the check // so... it didn't clear the check, but email is off so just remove bad email address and call it good // failed the check