Skip to content

Commit

Permalink
Merge branch 'Sahil1786:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Pruthaa17 committed Jun 4, 2024
2 parents 3e3852d + 95281fc commit 4a4106a
Show file tree
Hide file tree
Showing 19 changed files with 241 additions and 50 deletions.
90 changes: 90 additions & 0 deletions public/js/validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Example starter JavaScript for disabling form submissions if there are invalid fields
(() => {
'use strict'

// Fetch all the forms we want to apply custom Bootstrap validation styles to
const forms = document.querySelectorAll('.needs-validation')

// Loop over them and prevent submission
Array.from(forms).forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}

form.classList.add('was-validated')
}, false)
});

// Password validation script
var passwordInput = document.getElementById('password');

passwordInput.addEventListener('input', function () {
var passwordValue = passwordInput.value;
var passwordPattern = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/;

if (passwordPattern.test(passwordValue)) {
passwordInput.setCustomValidity('');
} else {
passwordInput.setCustomValidity('Invalid');
}
});

// Name validation script
var nameInput = document.getElementById('name');

nameInput.addEventListener('input', function () {
var nameValue = nameInput.value;
if (nameValue.length >= 4) {
nameInput.setCustomValidity('');
} else {
nameInput.setCustomValidity('Invalid');
}
});

// Email validation script
var emailInput = document.getElementById('email');

emailInput.addEventListener('input', function () {
var emailValue = emailInput.value;
// Regex pattern to validate email
var emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

if (emailPattern.test(emailValue)) {
emailInput.setCustomValidity('');
} else {
emailInput.setCustomValidity('Invalid');
}
});

// Mobile number validation script
var mobileInput = document.getElementById('mobn');
// var mobileFeedback = document.getElementById('mobileFeedback');

mobileInput.addEventListener('input', function () {
var mobileValue = mobileInput.value;
// Regex pattern to validate mobile number
var mobilePattern = /^\d{3}\d{3}\d{4}$/;

if (mobilePattern.test(mobileValue)) {
mobileInput.setCustomValidity('');
} else {
mobileInput.setCustomValidity('Invalid');
}
});

// NGO ID validation script
var NGOIDInput = document.getElementById('ngoid');

NGOIDInput.addEventListener('input', function () {
var nameValue = NGOIDInput.value;
if (nameValue.length >= 4) {
NGOIDInput.setCustomValidity('');
} else {
NGOIDInput.setCustomValidity('Invalid');
}
});


})()
7 changes: 4 additions & 3 deletions routers/NgoRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ router.post("/NGO-Registarion", async (req, res) => {
});

console.log("NGO registration request sent for approval");
res
.status(200)
.json({ message: "NGO registration request sent for approval" });
// res
// .status(200)
// .json({ message: "NGO registration request sent for approval" });
res.render("success")
} catch (err) {
console.error("Error creating NGO:", err);
res.status(500).json({ error: "Internal server error" });
Expand Down
2 changes: 1 addition & 1 deletion views/Admin_Dashboard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@

<!-- //icon -->
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.8/css/line.css">

<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
<title>Admin DashBoard</title>
</head>

Expand Down
1 change: 1 addition & 0 deletions views/Email.template.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Successful</title>
<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
<!-- Consider linking an external stylesheet here -->
<style>
body {
Expand Down
2 changes: 1 addition & 1 deletion views/NGO-Dashboard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;500;600&display=swap');
</style>
Expand Down
47 changes: 34 additions & 13 deletions views/NGO-Registration.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -97,31 +97,51 @@
<header class="header">NGO Registration Form</header>
<br>
<hr>
<form action="/NGO-Registarion" class="form custom-box" method="POST">
<form action="/NGO-Registarion" class="form custom-box needs-validation" method="POST" novalidate >
<div class="input-box">
<label>NGO Name</label>
<input type="text" name="NgoName" placeholder="Enter NGO name" required />
<label class="form-label">NGO Name</label>
<input id="name" class="form-control" type="text" name="NgoName" placeholder="Enter NGO name" required />
<div class="valid-feedback">
Name field looks good!
</div>
<div id="nameFeedback" class="invalid-feedback">
Name should be at least 4 characters long!
</div>
</div>

<div class="input-box">
<label>Email Address</label>
<input type="text" name="username" placeholder="Enter email address" required />
<label class="form-label">Email Address</label>
<input id="email" class="form-control" type="email" name="username" placeholder="Enter email address" required />
<div class="valid-feedback">Email field looks good!</div>
<div id="emailFeedback" class="invalid-feedback">Please enter a valid email address (e.g., user@example.com).</div>
</div>

<div class="input-box">
<label>Password</label>
<input type="password" name="password" placeholder="Enter password" required />
<label class="form-label">Password</label>
<input id="password" class="form-control" type="password" name="password" placeholder="Enter password" required />
<div class="valid-feedback">Password field looks good!</div>
<div class="invalid-feedback" id="passwordFeedback">Password must be at least 8 characters long and include an uppercase letter, a lowercase letter, a digit, and a special symbol.</div>
</div>

<div class="input-box">
<label>Mobile Number</label>
<input type="number" name="Mobile" placeholder="Enter mobile number" required />
<label class="form-label">Mobile Number</label>
<input id="mobn" class="form-control" type="text" name="Mobile" placeholder="Enter mobile number" required />
<div class="valid-feedback">Mobile number looks good!</div>
<div id="mobnFeedback" class="invalid-feedback">Mobile number should be exactly 10 digits long.</div>
</div>

<div class="input-box">
<label>NGO ID</label>
<input type="text" name="NgoID" placeholder="Enter NGO ID" required />
<label class="form-label">NGO ID</label>
<input id="ngoid" class="form-control" type="text" name="NgoID" placeholder="Enter NGO ID" required />
<div class="valid-feedback">NGO ID looks good!</div>
<div id="ngoidFeedback" class="invalid-feedback">NGO ID should be at least 4 characters long!</div>
</div>

<div class="input-box">
<label>NGO Location</label>
<input type="text" name="NgoLocation" placeholder="Enter NGO location" required />
<label class="form-label">NGO Location</label>
<input id="ngoloc" class="form-control" type="text" name="NgoLocation" placeholder="Enter NGO location" required />
<div class="valid-feedback">NGO location looks good!</div>
<div id="ngolocFeedback" class="invalid-feedback">Please enter a valid location (e.g., New York, NY).</div>
</div>

<button type="submit" id="signup-btn">Submit</button>
Expand Down Expand Up @@ -155,6 +175,7 @@
</script>

<script src="js/index.js"></script>
<script src="js/validation.js"></script>

</body>
</html>
10 changes: 8 additions & 2 deletions views/Ngo_login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@
<p>We are happy to have you back.</p>

</div>
<form action="/Ngo-login" method="POST">
<form action="/Ngo-login" method="POST" novalidate class="needs-validation">
<div class="input-group mb-3">
<input type="text" name="username" class="form-control form-control-lg bg-light fs-6" placeholder="Email address" required>
<input id="email" type="email" name="username" class="form-control form-control-lg bg-light fs-6" placeholder="Email address" required>
<div class="valid-feedback">Email field looks good!</div>
<div class="invalid-feedback">Please enter a valid email address (e.g., user@example.com).</div>
</div>
<div class="input-group mb-1">
<input type="password" name="password" class="form-control form-control-lg bg-light fs-6" placeholder="Password" required>
<div class="valid-feedback">Password field looks good!</div>
<div class="invalid-feedback">Password is required</div>
</div>
<div class="input-group mb-5 d-flex justify-content-between">
<div class="form-check">
Expand Down Expand Up @@ -103,5 +107,7 @@
});
</script>

<script src="js/validation.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion views/UserDashBoard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;500;600&display=swap');
Expand Down
44 changes: 32 additions & 12 deletions views/User_singUp.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,47 @@ body {
<header class="header">User Signup Form</header>
<br>
<hr>
<form action="/User_singUp" class="form custom-box" method="POST">
<form action="/User_singUp" class="form custom-box needs-validation" method="POST" novalidate >
<div class="input-box">
<label>Full Name</label>
<input type="text" name="fname" placeholder="Enter full name" required />
<label class="form-label">Full Name</label>
<input id="name" class="form-control" type="text" name="fname" placeholder="Enter full name" required />
<div class="valid-feedback">
Name field looks good!
</div>
<div id="nameFeedback" class="invalid-feedback">
Name should be at least 4 characters long!
</div>
</div>

<div class="input-box">
<label>Email Address</label>
<input type="text" name="username" placeholder="Enter email address" required />
<label class="form-label">Email Address</label>
<input id="email" class="form-control" type="email" name="username" placeholder="Enter email address" required />
<div class="valid-feedback">Email field looks good!</div>
<div id="emailFeedback" class="invalid-feedback">Please enter a valid email address (e.g., user@example.com).</div>
</div>
<div class="input-box">
<label>Password</label>
<input type="password" name="password" placeholder="Enter password" required />
<label class="form-label">Password</label>
<input id="password" class="form-control" type="password" name="password" placeholder="Enter password" required />
<div class="valid-feedback">Password field looks good!</div>
<div class="invalid-feedback" id="passwordFeedback">Password must be at least 8 characters long and include an uppercase letter, a lowercase letter, a digit, and a special symbol.</div>
</div>
<div class="input-box">
<label>Phone Number</label>
<input type="number" name="phn" placeholder="Enter phone number" required />
<label>Address</label>
<input type="text" name="address" placeholder="Enter address" required />
<div>
<label class="form-label">Phone Number</label>
<input id="mobn" class="form-control" type="number" name="phn" placeholder="Enter phone number" required />
<div class="valid-feedback">Mobile number looks good!</div>
<div id="mobnFeedback" class="invalid-feedback">Mobile number should be exactly 10 digits long.</div>
</div>
<div>
<label class="form-label">Address</label>
<input class="form-control" type="text" name="address" placeholder="Enter address" required />
<div class="valid-feedback">NGO location looks good!</div>
<div id="ngolocFeedback" class="invalid-feedback">Please enter a valid location (e.g., New York, NY).</div>
</div>
</div>
<div class="column">
<div class="input-box">
<label>Birth Date</label>
<label >Birth Date</label>
<input type="date" name="dob" placeholder="Enter birth date" required />
</div>
</div>
Expand Down Expand Up @@ -173,5 +191,7 @@ body {
</script>
<script src="js/index.js"></script>
<script src="js/validation.js"></script>

</body>
</html>
9 changes: 7 additions & 2 deletions views/admin_login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@
<p>We are happy to have you back.</p>

</div>
<form action="/admin-login" method="POST">
<form action="/admin-login" method="POST" novalidate class="needs-validation">
<div class="input-group mb-3">
<input type="text" name="email" class="form-control form-control-lg bg-light fs-6" placeholder="Email address" required>
<input id="email" type="email" name="email" class="form-control form-control-lg bg-light fs-6" placeholder="Email address" required>
<div class="valid-feedback">Email field looks good!</div>
<div class="invalid-feedback">Please enter a valid email address (e.g., user@example.com).</div>
</div>
<div class="input-group mb-1">
<input type="password" name="password" class="form-control form-control-lg bg-light fs-6" placeholder="Password" required>
<div class="valid-feedback">Password field looks good!</div>
<div class="invalid-feedback">Password is required</div>
</div>
<div class="input-group mb-5 d-flex justify-content-between">
<div class="form-check">
Expand Down Expand Up @@ -102,5 +106,6 @@
});
</script>
<script src="js/validation.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions views/comfirm.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
flex: 0 0 5%;
}
</style>
<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
</head>

<body>
Expand Down
1 change: 1 addition & 0 deletions views/forget-password.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
<!-- <link rel="stylesheet" href="/public/css/index.css"> -->
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,200&display=swap');
Expand Down
3 changes: 2 additions & 1 deletion views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Petari</title>
<link rel="shortcut icon" href="public/img/logo.png" type="image/x-icon">
<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
<!-- <link rel="shortcut icon" href="public/img/logo.png" type="image/x-icon"> -->

<link rel="stylesheet" href="/css/style.css">
<!-- Icon -->
Expand Down
3 changes: 2 additions & 1 deletion views/loginError.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
<title>Login Error</title>
</head>

Expand All @@ -16,4 +17,4 @@
<p><a href="/user_login">Go back to login</a></p>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion views/policies.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<link rel="stylesheet" href="/css/policies.css" />
<link rel="stylesheet" href="/css/style.css">

<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
<!-- Icon -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
Expand Down
1 change: 1 addition & 0 deletions views/registrationError.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Error</title>
<link rel="shortcut icon" href="img/logo.png" type="image/x-icon">
</head>
<body>
<h1>Registration Error</h1>
Expand Down
Loading

0 comments on commit 4a4106a

Please sign in to comment.