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

Update index.html #49

Closed
wants to merge 1 commit into from
Closed
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
34 changes: 20 additions & 14 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@

<body>
<div class="main">
<div class="navbar">
<div class="menu">
<header class="navbar">
<nav class="menu">
<ul>
<li><a href="see_details.html">See Details</a></li>
</ul>
</div>
</div>
</nav>
</header>

<div class="content">
<main class="content">
<h1>Grand <span>Event</span> <br>Celebration</h1>
<form id="myform" action="/submit" method="post" enctype="multipart/form-data">
<div class="form">
<h2>Register Here</h2>
<input type="text" id="roll" name="roll" placeholder="Enter Your Class Roll" required>
<input type="text" id="fullname" name="fullname" placeholder="Enter Your Full Name" required>
<input type="email" id="email" name="email" placeholder="Enter Email Address" required>
<input type="text" id="phno" name="phno" placeholder="Enter Phone Number" required>
<input type="text" id="phno" name="phno" placeholder="Enter Phone Number" required pattern="\d{10}">

<div class="form-group">
<label for="profile">Upload Profile Picture</label>
Expand Down Expand Up @@ -65,7 +65,7 @@ <h2>Register Here</h2>

<!-- QR Code Section -->
<div id="qrcode"></div> <!-- This is where the QR code will be displayed -->
</div>
</main>
</div>

<script>
Expand All @@ -80,6 +80,11 @@ <h2>Register Here</h2>
field.closest(".form").appendChild(errorElement);
}

const clearErrors = () => {
document.querySelectorAll(".form .error").forEach(field => field.classList.remove("error"));
document.querySelectorAll(".error-text").forEach(errorText => errorText.remove());
}

const handleFormData = (e) => {
e.preventDefault();

Expand All @@ -98,8 +103,7 @@ <h2>Register Here</h2>
const emailPattern = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;

// Clear existing errors
document.querySelectorAll(".form .error").forEach(field => field.classList.remove("error"));
document.querySelectorAll(".error-text").forEach(errorText => errorText.remove());
clearErrors();

// Validation checks
if (fullname === "") {
Expand All @@ -108,9 +112,7 @@ <h2>Register Here</h2>
if (!emailPattern.test(email)) {
showError(emailInput, "Enter a valid email address");
}
if (phno === "") {
showError(phnoInput, "Enter your phone number");
} else if (phno.length != 10) {
if (!/^\d{10}$/.test(phno)) {
showError(phnoInput, "Phone number should be 10 digits");
}
if (stream === "") {
Expand All @@ -129,8 +131,12 @@ <h2>Register Here</h2>

// Generate QR code
QRCode.toCanvas(qrCodeDiv, qrData, function (error) {
if (error) console.error(error);
console.log('QR Code generated!');
if (error) {
console.error(error);
} else {
console.log('QR Code generated!');
alert('QR Code generated successfully!'); // Added user feedback
}
});
}

Expand Down