function captcha(msgEquation1, result, msgEquation2) { // the captcha is making use of PHP variables
  const human = document.getElementById('human');
  const answer = Number(document.getElementById('human').value);
  const humanFeedback = document.getElementById('human-feedback');
  if (answer !== Number(result)) { // ---- result is incorrect
    human.classList.add('is-invalid');
    if (human.classList.contains('is-valid'))
      human.classList.remove('is-valid');
    humanFeedback.innerHTML = msgEquation1 + answer + msgEquation2;
    humanFeedback.classList.add('invalid-human-feedback');
    if (humanFeedback.classList.contains('valid-human-feedback'))
      humanFeedback.classList.remove('valid-human-feedback');
  }
  else { // ---- result is correct
    human.classList.add('is-valid');
    if (human.classList.contains('is-invalid'))
      human.classList.remove('is-invalid');
    humanFeedback.innerHTML = '&nbsp;';
  }
}
/**
 * Check the captcha answer while it's changed.
 * @param msgEquation1
 * @param result
 * @param msgEquation2
 */
Check the captcha answer while it's changed.
Check the captcha answer while it ' s changed .
function captcha(msgEquation1, result, msgEquation2) { 
  const human = document.getElementById('human');
  const answer = Number(document.getElementById('human').value);
  const humanFeedback = document.getElementById('human-feedback');
  if (answer !== Number(result)) { 
    human.classList.add('is-invalid');
    if (human.classList.contains('is-valid'))
      human.classList.remove('is-valid');
    humanFeedback.innerHTML = msgEquation1 + answer + msgEquation2;
    humanFeedback.classList.add('invalid-human-feedback');
    if (humanFeedback.classList.contains('valid-human-feedback'))
      humanFeedback.classList.remove('valid-human-feedback');
  }
  else { 
    human.classList.add('is-valid');
    if (human.classList.contains('is-invalid'))
      human.classList.remove('is-invalid');
    humanFeedback.innerHTML = '&nbsp;';
  }
}
function captcha ( msgEquation1 , result , msgEquation2 ) { const human = document . getElementById ( 'human' ) ; const answer = Number ( document . getElementById ( 'human' ) . value ) ; const humanFeedback = document . getElementById ( 'human-feedback' ) ; if ( answer !== Number ( result ) ) { human . classList . add ( 'is-invalid' ) ; if ( human . classList . contains ( 'is-valid' ) ) human . classList . remove ( 'is-valid' ) ; humanFeedback . innerHTML = msgEquation1 + answer + msgEquation2 ; humanFeedback . classList . add ( 'invalid-human-feedback' ) ; if ( humanFeedback . classList . contains ( 'valid-human-feedback' ) ) humanFeedback . classList . remove ( 'valid-human-feedback' ) ; } else { human . classList . add ( 'is-valid' ) ; if ( human . classList . contains ( 'is-invalid' ) ) human . classList . remove ( 'is-invalid' ) ; humanFeedback . innerHTML = '&nbsp;' ; } }
Check the captcha answer while it's changed.
Check the captcha answer while it ' s changed .
// the captcha is making use of PHP variables // ---- result is incorrect // ---- result is correct