I gift free tickets to students for free entry into a training class and I write each student’s phone number on their ticket to prevent another student from using a stolen ticket for entry.
I am trying to design a form for the students to register as candidates and also to have their data.
On the form, I want them to input their phone number and the unique code that is printed on the ticket that I gifted to them.
I am trying to make only students with my ticket be able to submit the form.
How do I prevent form submission with javascript when the phone number and the ticket number do not match?
Below is a sample of a javascript that I use to prevent form submission when email does not match.
I am aware that the sample below is not the best solution but I still need the solution. Thanks.
Code Sample;
function check_email()
{
var email = document.getElementById("email").value;
if(email.localeCompare("[email protected]" || "[email protected]")) {
alert("ATTENTION! nThe email address that you provided did not match with the email that is associated.");
return false;
}
return true;
}
<form action='' onsubmit="return check_email();">
<input type="password" name="email" placeholder="go*****b@*****.com" required='' id="email"/>
<button href='/' type='submit' id="submitForm">Submit</button> <button class="button" type="reset" value="Cancel">Reset</button>
</form>