I’m new to web design, and I created this HTML form, but I want it to also have a simple captcha.I want the form to be submitted only if the required values are correct.
<form id="captcha" action="" method="post">
<input type="text" name="engagement" placeholder="Your name">
/** then the user has to enter the value in cap1 into cap2. before he can submit the form */
<input id="cap1" type="text" name="time1" value="123">
<input id="cap2" type="text">
<button type="submit" id="button">Join</button>
</form>
<script>
/** this was my trash code which i couldn't complete */
const captcha = document.getElementById('captcha'),
cap1 = document.getElementById('cap-1'),
cap2 = document.getElementById('cap-2');
</script>
Please, if possible, add an alert when the person inputs the wrong value.