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

🛠️FIX :Name validation added on contact us section #727

Merged
merged 3 commits into from
Nov 6, 2024
Merged
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
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,15 @@ <h2>Contact Our Customer Support Team</h2>
<form id="contactForm">
<div class="form-group">
<label for="name"><i class="fas fa-user"></i> Name</label>
<input type="text" id="name" name="name" placeholder="Your name">
<input type="text" id="name" name="name" placeholder="Your name" required >
</div>
<div class="form-group">
<label for="email"><i class="fas fa-envelope"></i> Email</label>
<input type="email" id="email" name="email" placeholder="Your email">
<input type="email" id="email" name="email" placeholder="Your email" required>
</div>
<div class="form-group">
<label for="message"><i class="fas fa-comment"></i> Message</label>
<textarea id="message" name="message" placeholder="Your message"></textarea>
<textarea id="message" name="message" placeholder="Your message" required></textarea>
</div>
<button type="submit">Send</button>
</form>
Expand Down
12 changes: 12 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,15 @@ function displayVisitorCount() {
// Call the display function when the page loads
document.addEventListener('DOMContentLoaded', displayVisitorCount);

//Name validation function on index page , Contact us section

const nameInput = document.getElementById('name');

nameInput.addEventListener('input', () => {
const name = nameInput.value.trim();
if (!/^[a-zA-Z ]+$/.test(name)) {
nameInput.setCustomValidity('Numbers and symbols are not allowed');
} else {
nameInput.setCustomValidity('');
}
});