79253152

Date: 2024-12-05 01:27:20
Score: 1
Natty:
Report link

Thank you very much All! I have got it working with all your help actually. So it needed preventDefault() which I had missing. I also took on board another advice to move my logics. Current JavaScript is below. It might still become fickle upon introducing further functionalities but so far so good ;)

let inputValidator = (val) => {
  val = nameInput.value;
  if (val.length > 15 || /[0-9.*+?><,#^=!:${}()|\[\]\/\\]+/g.test(val)) {
    return `No numbers or special characters and no more than 15 characters allowed`;
  } else {
    console.log(val);
    return val;
  }
};

function greeting() {
  questions.innerHTML = `Hi ${inputValidator()}`
}

let clickStart = () => {
  okBtn.addEventListener("click", e => {
    e.preventDefault();
    greeting();
  });
};
clickStart();
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: donnie darko