Skip to content

Commit

Permalink
Merge pull request #939 from sayanp607/register
Browse files Browse the repository at this point in the history
Register page done
  • Loading branch information
ankit071105 authored Nov 10, 2024
2 parents 0d3a7ad + cfa63a8 commit 7e62a76
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions register.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
<!-- Tailwind CSS CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<style>
/* CSS for styling the form */
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
flex-direction: column; /* Stack elements vertically */
justify-content: flex-start; /* Align items at the top */
align-items: center; /* Center items horizontally */
margin: 0;
padding: 20px; /* Add padding to the body for spacing */
background-color: #f0f0f0;
:root {
--primary-color: #6366f1; /* Indigo */
--primary-hover: #4338ca; /* Indigo darker */
Expand Down Expand Up @@ -62,6 +76,12 @@
}

.form-field input {
width: 100%;
width: 95%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
width: 100%;
padding: 12px 16px;
border: 2px solid #d1d5db; /* Gray-300 */
Expand Down Expand Up @@ -109,6 +129,85 @@
}
</style>
</head>
<body>

<div class="registration-form">
<h2>Register</h2>
<div class="form-field">
<label for="email">Email</label>
<input type="email" id="email" placeholder="Enter your email" required>
</div>
<div class="form-field">
<label for="username">Username</label>
<input type="text" id="username" placeholder="Enter your username" required>
</div>
<div class="form-field">
<label for="mobile">Mobile</label>
<input type="text" id="mobile" placeholder="Enter your mobile number" required>
</div>
<div class="form-field">
<label for="password">Password</label>
<input type="password" id="password" placeholder="Enter your password" required>
</div>
<div class="form-field">
<button onclick="registerUser()">Register</button>
<a href="./index.html">Back to Home</a>
</div>
<div id="message" class="message"></div>
</div>

<script>
// JavaScript for registration logic and validation
function registerUser() {
const email = document.getElementById('email').value.trim();
const username = document.getElementById('username').value.trim();
const mobile = document.getElementById('mobile').value.trim();
const password = document.getElementById('password').value.trim();
const messageElement = document.getElementById('message');

// Basic validation
if (!email || !username || !mobile || !password) {
showMessage('All fields are required!', 'error');
return;
}

// Email validation
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
showMessage('Invalid email format!', 'error');
return;
}

// Username validation
if (username.length < 3) {
showMessage('Username must be at least 3 characters long!', 'error');
return;
}

// Mobile number validation
if (!/^\d{10}$/.test(mobile)) {
showMessage('Mobile number must be 10 digits!', 'error');
return;
}

// Password validation
if (password.length < 6) {
showMessage('Password must be at least 6 characters long!', 'error');
return;
}

// If all validations pass, display success message
showMessage('Registration successful!', 'success');
}

// Function to display messages
function showMessage(message, type) {
const messageElement = document.getElementById('message');
messageElement.textContent = message;
messageElement.className = `message ${type}`;
}
</script>

<header>
<nav class="navbar">
<img src="https://ticket-booking-blue.vercel.app/images/4.jpeg" alt="" style="border-radius: 50%; height: 35px; width: 35px;">
Expand Down

0 comments on commit 7e62a76

Please sign in to comment.