JavaScriptJavaScript · Lesson 12Forms & ValidationReading values, preventDefault and custom checks.Video tutorialTrack course · freeCodeCampJavaScript Full Course for Beginners Speed0.75x1x1.25x1.5x2x Skip intro Next lessonWatch 00:00 · 1 checkpoints Watch on YouTube More on this topic Transcript & captions .txt2/200:00Forms & Validation. Reading values, preventDefault and custom checks.00:05Try it yourself — edit the sample and run it in the browser.Try it yourself Copy Reset Run<form id="f" style="font-family:system-ui"> <input name="email" placeholder="you@mail.com"> <button>Send</button> </form> <p id="out"></p> <script> f.addEventListener('submit', (e) => { e.preventDefault(); const data = Object.fromEntries(new FormData(f)); const ok = /^[^@\s]+@[^@\s]+\.[a-z]{2,}$/i.test(data.email || ''); out.textContent = ok ? 'Valid: ' + data.email : 'Please enter a valid email'; out.style.color = ok ? 'green' : 'crimson'; }); </script>Knowledge check0/1 answeredWhat stops a form from reloading the page?return false onlyevent.preventDefault()form.stop()Mark as complete PreviousEventsNext Async JavaScript