Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Trusted email validation functionality in Signup form #252

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ class="mt-8 flex flex-col gap-10 items-center justify-center sm:flex-row sm:item
<div class="block">
<h2 class="font-semibold text-gray-800 text-lg">Get in touch</h2>
<div class="flex flex-col gap-2 text-[#6A6E5C] mt-2">
<a href="#">[email protected]</a>
<a href="#">+91 9820223338</a>
<a href="mailto:[email protected]">[email protected]</a>
<a href="callto:+919820223338">+91 9820223338</a>
</div>
</div>
<div class="block">
Expand Down
46 changes: 44 additions & 2 deletions user_signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -185,6 +186,47 @@ 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;

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");
Expand Down