Skip to content

Commit

Permalink
Merge pull request #727 from akash70629/main
Browse files Browse the repository at this point in the history
🛠️FIX :Name validation added on contact us section
  • Loading branch information
swaraj-das authored Nov 6, 2024
2 parents fd2ac2c + d9ba437 commit 3cf72c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -622,15 +622,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('');
}
});

0 comments on commit 3cf72c4

Please sign in to comment.