Build an Event RSVP - Test #13

Tell us what’s happening:

The tester is failing test #13 (don’t refresh the page on Submit) for me. I took a look at what the tester is doing, and it fires a mock Submit event with preventDefault() monkey-patched to check that it’s being called and nothing else. My dev-tools show me a TypeError on the next line (but only for test #13), suggesting that the mock Event either doesn’t have an e.target or doesn’t have an e.target.checkValidity(). Should I be checking fields’ adherence to required and type=”email” attributes in a different way?

ADDENDUM: I got this to pass by changing the checkValidity() line to e.target?.checkValidity?.() (thanks, AI) — the conditionals shouldn’t matter for a real Event but allow the mock Event to work.

Your code so far

  const handleSubmit = e => {
    e.preventDefault();
    if (e.target.checkValidity())
      setSubmitted(true);
  }

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36

Challenge Information:

Build an Event RSVP - Build an Event RSVP

https://www.freecodecamp.org/learn/full-stack-developer/lab-event-rsvp/build-an-event-rsvp