-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added trusted email validation to signup form
- Loading branch information
Showing
1 changed file
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,14 +148,15 @@ | |
<div class="w-96 ml-auto flex flex-col gap-8"> | ||
<h1 class="text-3xl font-bold">Hello, Good to see you</h1> | ||
|
||
<form action="user_signup.php" method="post" class="flex flex-col gap-4"> | ||
<form action="user_signup.php" method="post" onsubmit="return validateEmail()" class="flex flex-col gap-4"> | ||
<div class="form-group"> | ||
<label for="name" class="mb-2">Name</label> | ||
<input type="text" id="name" name="name" placeholder="Enter your name" class="p-2 border border-black" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="email" class="mb-2">Email</label> | ||
<input type="email" id="email-id" name="email" placeholder="[email protected]" class="p-2 border border-black" required> | ||
<input type="email" id="email-id" name="email" placeholder="[email protected]" class="p-2 border border-black" required><br> | ||
<span id="email-error" class="text-red-500 text-sm hidden">Please enter a trusted email address.</span> | ||
</div> | ||
<div class="form-group"> | ||
<label for="password" class="mb-2">Password</label> | ||
|
@@ -185,6 +186,51 @@ class="flex items-center justify-center w-full p-2 border border-gray-300 rounde | |
</body> | ||
|
||
<script> | ||
|
||
function validateEmail() { | ||
const trustedDomains = [ | ||
'gmail.com', | ||
'outlook.com', | ||
'yahoo.com', | ||
'protonmail.com', | ||
'icloud.com', | ||
'tutanota.com', | ||
'hotmail.com', | ||
'live.com', | ||
'mail.com', | ||
'zoho.com', | ||
'gmx.com', | ||
'aol.com', | ||
'fastmail.com', | ||
'yandex.com', | ||
'*.edu', | ||
'*.ac.uk', | ||
'*.edu.in', | ||
'*.edu.au', | ||
'examplecompany.com', | ||
'mailfence.com', | ||
'posteo.de', | ||
'runbox.com', | ||
'countermail.com', | ||
'hushmail.com', | ||
'inbox.com', | ||
'mail.ru', | ||
'rediffmail.com', | ||
'seznam.cz' | ||
]; | ||
|
||
const email = document.getElementById("email-id").value; | ||
|
||
console.log(email+"email"); | ||
|
||
if (!trustedDomains.includes(email)) { | ||
document.getElementById("email-error").classList.remove("hidden"); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
const eyeBtnPassword =document.getElementById("eye-btn-p"); | ||
const eyeBtnConfirmPassword =document.getElementById("eye-btn-cp"); | ||
const passwordField =document.getElementById("password"); | ||
|