Commit bc107254 authored by Deep Dey's avatar Deep Dey

feat: add admission portal page for admin

parent 6fae70c0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Application For Admission - La Martiniere</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="./css/admission_portal.css">
</head>
<body>
<section class="la-body-container">
<div class="la-header">
<img src="https://i0.wp.com/lamartiniere.co/wp-content/uploads/2020/10/cropped-lmbb-logo-site-logo.png?w=240&ssl=1"
alt="" srcset="">
<div class="la-header-title">SUBMISSION OF APPLICATION FOR ADMISSION</div>
<div class="la-header-sub-title">Please <span>REVIEW</span> the form carefully before you submit your
application for admission</div>
</div>
<div class="la-form-container">
<form id="application-form">
<div class="la-form-group">
<label for="school">Choose your school <span>*</span></label>
<select name="school" class="la-form-control">
<option value="">Select an School</option>
<option value="La Martiniere for Boys">La Martiniere for Boys</option>
<option value="La Martiniere for Girls">La Martiniere for Girls</option>
</select>
<div class="la-invalid-feedback"></div>
<small>Please specify Choice of School</small>
</div>
<div class="la-form-group">
<label for="category">Category <span>*</span></label>
<select id="category" name="category" class="la-form-control">
<option value="">Specify Category</option>
<option value="General">General</option>
<option value="Brother / Sister">Brother /
Sister(Not Cousins) studying at La Martiniere, Kolkata</option>
<option value="Staff Child">Staff Child</option>
<option value="Ex-Student">Ex-Student</option>
</select>
<div class="la-invalid-feedback"></div>
<small>Please specify Category</small>
</div>
<div id="staffDepartmentContainer" class="la-form-group">
<label for="staffDepartment">Staff Department <span>*</span></label>
<select id="staffDepartment" name="staffDepartment" class="la-form-control">
<option value="">Specify Staff Department</option>
<option value="Teaching">Teaching</option>
<option value="Non-Teaching">Non-Teaching</option>
</select>
<div class="la-invalid-feedback"></div>
</div>
<div id="staffCategoryContainer" class="la-form-group">
<label for="staffCategory">Staff Category <span>*</span></label>
<select id="staffCategory" name="staffCategory" class="la-form-control">
<option value="">Specify Staff Category</option>
<option value="Permanent">Permanent</option>
<option value="On Probation">On Probation</option>
<option value="Contractual">Contractual</option>
</select>
<div class="la-invalid-feedback"></div>
</div>
<div id="exStudentInfoContainer" class="la-form-group">
<label for="exStudentInfo">Parent who is/are ex-student <span>*</span></label>
<select id="exStudentInfo" name="exStudentInfo" class="la-form-control">
<option value="">Mention Parent who is/are ex-student</option>
<option value="Father">Father is an ex-student</option>
<option value="Mother">Mother is an ex-student</option>
<option value="Both">Both Father and Mother are ex-students</option>
</select>
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fullName">Full Name <span>*</span></label>
<input type="text" name="fullName" class="la-form-control">
<div class="la-invalid-feedback"></div>
<small>As given in the Municipal Corporation Birth Certificate/Baptism Certificate</small>
</div>
<div class="la-form-group">
<label for="admissionClass">Class <span>*</span></label>
<select name="admissionClass" class="la-form-control">
<option value="">Specify Class</option>
<option value="Lower Nursery">Lower Nursery</option>
<!-- <option value="Upper Nursery">Upper Nursery</option> -->
</select>
<div class="la-invalid-feedback"></div>
<small>Please specify class in which admission is sought. (based on the selection of Class – the year of Birth is automatically fixed)</small>
</div>
<div class="la-form-group">
<label for="dateOfBirth">Date of Birth <span>*</span></label>
<input type="date" name="dateOfBirth" id="dateOfBirth" class="la-form-control">
<div class="la-invalid-feedback"></div>
<small>Date of Birth - as given in the Municipal Corporation Birth Certificate/Baptism Certificate</small>
</div>
<div class="la-form-group">
<label for="nationality">Nationality <span>*</span></label>
<input type="text" name="nationality" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="religion">Religion <span>*</span></label>
<select id="religion" name="religion" class="la-form-control">
<option value="">Specify Religion</option>
<option value="Christian">Christian</option>
<option value="Hindu">Hindu</option>
<option value="Muslim">Muslim</option>
<option value="Sikh">Sikh</option>
<option value="Buddhist">Buddhist</option>
<option value="Jain">Jain</option>
<option value="Other">Other</option>
</select>
<div class="la-invalid-feedback"></div>
</div>
<div id="denominationContainer" class="la-form-group">
<label for="denomination">Denomination <span>*</span></label>
<input id="denomination" type="text" name="denomination" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div id="churchContainer" class="la-form-group">
<label for="church">Church <span>*</span></label>
<input id="church" type="text" name="church" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherTongue">Mother Tongue <span>*</span></label>
<input type="text" name="motherTongue" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="community">Community <span>*</span></label>
<input type="text" name="community" class="la-form-control">
<div class="la-invalid-feedback"></div>
<small>Socio- Linguistic community (eg Bengali, Punjabi, Marwari, Jain etc.)</small>
</div>
<div class="la-form-group">
<label for="homeAddress">Home Address <span>*</span></label>
<input id="homeAddress" type="text" name="homeAddress" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group form-check">
<input class="form-check-input" type="checkbox" value="" id="addressCheck">
<label class="form-check-label" for="flexCheckDefault">
Correspondence Address same as Home Address
</label>
</div>
<div class="la-form-group">
<label for="correspondenceAddress">Correspondence Address <span>*</span></label>
<input id="correspondenceAddress" type="text" name="correspondenceAddress" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="otherChildren">Details of Other Children</label>
<input type="text" name="otherChildren" class="la-form-control">
<div class="la-invalid-feedback"></div>
<small>Please Specify Name, Age, Current School and Class</small>
</div>
<!-- start of parent information -->
<h4>PARENT INFORMATION</h4>
<div class="la-form-group">
<label for="maritalStatus">Marital Status <span>*</span></label>
<select id="maritalStatus" name="maritalStatus" class="la-form-control">
<option value="">Choose an option</option>
<option value="Married">Married</option>
<option value="Separated">Separated</option>
<option value="Divorced">Divorced</option>
<option value="Single">Single</option>
</select>
<div class="la-invalid-feedback"></div>
<small>Mother information is mandatory for <b>Married</b></small>
</div>
<!-- Father Information -->
<h4>DETAILS OF FATHER / GUARDIAN</h4>
<div class="la-form-group">
<label for="fatherName">Full Name <span>*</span></label>
<input type="text" name="fatherName" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group form-check">
<input id="duplicateFatherEmail" name="duplicateFatherEmail" class="form-check-input" type="checkbox" value="">
<label class="form-check-label" for="flexCheckDefault">
Please check this, If you have twins and already filled this form before with a email address and use the same email here.
</label>
</div>
<div class="la-form-group">
<label for="fatherEmail">Email <span>*</span></label>
<input type="email" name="fatherEmail" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherMobile">Phone <span>*</span></label>
<input type="text" name="fatherMobile" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherNationality">Nationality <span>*</span></label>
<input type="text" name="fatherNationality" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherReligion">Religion <span>*</span></label>
<select id="fatherReligion" name="fatherReligion" class="la-form-control">
<option value="">Specify Religion</option>
<option value="Christian">Christian</option>
<option value="Hindu">Hindu</option>
<option value="Muslim">Muslim</option>
<option value="Sikh">Sikh</option>
<option value="Buddhist">Buddhist</option>
<option value="Jain">Jain</option>
<option value="Other">Other</option>
</select>
<div class="la-invalid-feedback"></div>
</div>
<div id="fatherDenominationContainer" class="la-form-group">
<label for="fatherDenomination">Denomination <span>*</span></label>
<input id="fatherDenomination" type="text" name="fatherDenomination" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div id="fatherChurchContainer" class="la-form-group">
<label for="fatherChurch">Church <span>*</span></label>
<input id="fatherChurch" type="text" name="fatherChurch" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherMotherTongue">Mother Tongue <span>*</span></label>
<input type="text" name="fatherMotherTongue" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherCommunity">Community <span>*</span></label>
<input type="text" name="fatherCommunity" class="la-form-control">
<div class="la-invalid-feedback"></div>
<small>Socio- Linguistic community (eg Bengali, Punjabi, Marwari, Jain etc.)</small>
</div>
<div class="la-form-group">
<label for="fatherSchoolInfo">School, Name of Institution, Examination
Passed <span>*</span></label>
<input type="text" name="fatherSchoolInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherCollegeInfo">College Examination Passed</label>
<input type="text" name="fatherCollegeInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherUniversityInfo">University Examination Passed</label>
<input type="text" name="fatherUniversityInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherProfessionalQualification">Professional Qualification/s Passed</label>
<input type="text" name="fatherProfessionalQualification" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherOccupation">Occupation and Designation <span>*</span></label>
<input type="text" name="fatherOccupation" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherMonthlyIncome">Monthly Income <span>*</span></label>
<input type="text" name="fatherMonthlyIncome" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="fatherWorkplaceInfo">Name of Organisation, Address and Telephone No/s</label>
<input type="text" name="fatherWorkplaceInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<!-- end of Father Information -->
<!-- Mother Information -->
<h4>DETAILS OF MOTHER</h4>
<div class="la-form-group">
<label for="motherName">Full Name <span>*</span></label>
<input id="motherName" type="text" name="motherName" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherEmail">Email <span>*</span></label>
<input id="motherEmail" type="email" name="motherEmail" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherMobile">Phone <span>*</span></label>
<input id="motherMobile" type="text" name="motherMobile" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherNationality">Nationality <span>*</span></label>
<input id="motherNationality" type="text" name="motherNationality" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherReligion">Religion <span>*</span></label>
<select id="motherReligion" name="motherReligion" class="la-form-control">
<option value="">Specify Religion</option>
<option value="Christian">Christian</option>
<option value="Hindu">Hindu</option>
<option value="Muslim">Muslim</option>
<option value="Sikh">Sikh</option>
<option value="Buddhist">Buddhist</option>
<option value="Jain">Jain</option>
<option value="Other">Other</option>
</select>
<div class="la-invalid-feedback"></div>
</div>
<div id="motherDenominationContainer" class="la-form-group">
<label for="motherDenomination">Denomination <span>*</span></label>
<input id="motherDenomination" type="text" name="motherDenomination" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div id="motherChurchContainer" class="la-form-group">
<label for="motherChurch">Church <span>*</span></label>
<input id="motherChurch" type="text" name="motherChurch" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherMotherTongue">Mother Tongue <span>*</span></label>
<input id="motherMotherTongue" type="text" name="motherMotherTongue" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherCommunity">Community <span>*</span></label>
<input id="motherCommunity" type="text" name="motherCommunity" class="la-form-control">
<div class="la-invalid-feedback"></div>
<small>Socio- Linguistic community (eg Bengali, Punjabi, Marwari, Jain etc.)</small>
</div>
<div class="la-form-group">
<label for="motherSchoolInfo">School, Name of Institution, Examination
Passed <span>*</span></label>
<input id="motherSchoolInfo" type="text" name="motherSchoolInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherCollegeInfo">College Examination Passed</label>
<input type="text" name="motherCollegeInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherUniversityInfo">University Examination Passed</label>
<input type="text" name="motherUniversityInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherProfessionalQualification">Professional Qualification/s Passed</label>
<input type="text" name="motherProfessionalQualification" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherOccupation">Occupation and Designation <span>*</span></label>
<input id="motherOccupation" type="text" name="motherOccupation" class="la-form-control">
<div class="la-invalid-feedback"></div>
<small>If not working please write Homemaker/Housewife</small>
</div>
<div class="la-form-group">
<label for="motherMonthlyIncome">Monthly Income</label>
<input type="text" name="motherMonthlyIncome" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
<label for="motherWorkplaceInfo">Name of Organisation, Address and Telephone No/s</label>
<input type="text" name="motherWorkplaceInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<!-- end of Mother Information -->
<!-- end of parent information -->
<!-- Image section -->
<div class="form-image-group">
<div class="la-form-group">
<img id="candidateImage" class="image-preview" src="./img/candidate.png" alt="candidate photo">
<label for="candidateImage">Candidate's Photo</label>
<input type="file" name="candidateImage" class="la-form-control">
<div class="la-invalid-feedback text-center"></div>
</div>
<div class="la-form-group">
<img id="fatherImage" class="image-preview" src="./img/father.png" alt="father photo">
<label for="fatherImage" style="text-align: center;">Father's/Guardian's Photo</label>
<input type="file" name="fatherImage" class="la-form-control">
<div class="la-invalid-feedback text-center"></div>
</div>
<div class="la-form-group">
<img id="motherImage" class="image-preview" src="./img/mother.png" alt="mother photo">
<label for="motherImage">Mother's Photo</label>
<input id="motherImageInput" type="file" name="motherImage" class="la-form-control">
<div class="la-invalid-feedback text-center"></div>
</div>
</div>
<!-- end of image section -->
<div class="la-form-group form-check">
<input class="form-check-input" name="formSubmitCheck" type="checkbox" id="formSubmitCheck">
<label class="form-check-label text-justify" for="flexCheckDefault">
Please check this before submitting the form, and make sure that, the provided information is all correct because once submitted, it can't be changed.
</label>
</div>
<div class="form-btn">
<button type="submit" class="btn btn-sumbit" id="btn-sumbit">
<div class="loader"></div>
<div class="btn-text">Submit</span>
</button>
</div>
</form>
</div>
</section>
<div class="modal" tabindex="-1" role="dialog" id="messageModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body"></div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="./js/constant.js"></script>
<script src="./js/admission_portal.js"></script>
</body>
</html>
\ No newline at end of file
* {
margin: 0;
padding: 0;
}
body {
font-family: "Poppins", sans-serif;
font-style: normal;
background-color: #f1f1f1;
width: 100%;
height: 100%;
}
.la-body-container {
padding: 0px 100px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.la-header {
display: flex;
width: 100%;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: center;
}
.la-header-title {
font-size: 1.8rem;
font-weight: bold;
padding-top: 15px;
}
.la-header-sub-title {
font-size: 1rem;
}
.la-header-sub-title span {
font-weight: bold;
}
.la-form-container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 100%;
margin-top: 30px;
}
/* Form */
#application-form {
width: 60%;
padding-bottom: 30px;
}
.la-form-group {
width: 100%;
margin-bottom: 15px;
}
.la-form-group label {
display: block;
margin-bottom: 4px;
font-size: 13px;
color: #706c6c;
}
.la-form-group label.is-invalid {
color: crimson;
}
.la-form-group label span {
color: crimson;
font-weight: 600;
}
.la-form-group .la-form-control {
width: 100%;
padding: 8px;
box-sizing: border-box;
border: 1px solid #b9b7b7;
outline: none;
}
.la-form-group .la-form-control.is-invalid {
border: 1px solid crimson;
color: crimson;
}
.la-form-group .la-invalid-feedback,
.la-form-group small {
display: block;
margin-top: 3px;
color: #3c3939;
font-size: 11px;
}
.la-form-group .la-invalid-feedback {
color: crimson;
}
.form-btn {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.btn {
display: flex;
justify-content: center;
align-items: center;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .355rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
cursor: pointer;
}
.btn-sumbit {
width: 250px;
margin-top: 15px;
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
.btn-sumbit:hover {
color: #fff;
background-color: #0069d9;
border-color: #0062cc;
}
.form-image-group {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
margin-top: 30px;
}
.form-image-group .la-form-group {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
/* width: 30%; */
padding: 0px 10px;
}
.image-preview {
width: 100px;
height: 100px;
/* border: 1px solid #ddd; */
margin: 10px;
object-fit: cover;
}
.loader {
display: none;
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
width: 25px;
height: 25px;
animation: spin 2s linear infinite;
}
input[type="file"] {
font-size: 12px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@media only screen and (max-width: 768px) {
#application-form {
width: 100%;
}
.form-image-group{
display: flex;
flex-wrap: wrap;
/* flex-direction: column; */
}
.la-form-group{
width: 100%;
}
/* input[type="file"] {
width: 80%;
} */
.la-body-container {
padding: 0px 60px;
}
}
\ No newline at end of file
$(document).ready(function () {
$('#staffDepartmentContainer').hide();
$('#staffCategoryContainer').hide();
$('#exStudentInfoContainer').hide();
$('#denominationContainer').hide();
$('#churchContainer').hide();
$('#fatherDenominationContainer').hide();
$('#fatherChurchContainer').hide();
$('#motherDenominationContainer').hide();
$('#motherChurchContainer').hide();
$('#addressCheck').click(function () {
if ($(this).is(':checked')) {
$('#correspondenceAddress').prop('disabled', true)
$('#correspondenceAddress').val($('#homeAddress').val());
} else {
$('#correspondenceAddress').prop('disabled', false);
}
});
$('#homeAddress').on('input', function () {
if ($('#addressCheck').is(':checked')) {
$('#correspondenceAddress').val($('#homeAddress').val());
}
})
//TODO: depending on class it will set the min and max date
$('#dateOfBirth').click(function () {
var currentDate = new Date();
var currentYear = currentDate.getFullYear();
var upperLimitDate = new Date(currentYear - 1, 0, 1);
var lowerLimitDate = new Date(currentYear - 2, 0, 2);
// Format the dates as YYYY-MM-DD strings
var upperLimitDateString = upperLimitDate.toISOString().split('T')[0];
var lowerLimitDateString = lowerLimitDate.toISOString().split('T')[0];
$('#dateOfBirth').attr('max', upperLimitDateString);
$('#dateOfBirth').attr('min', lowerLimitDateString);
});
$('#category').on('change', function () {
if ($(this).val() === 'Staff Child') {
$('#staffDepartmentContainer').show();
$('#staffCategoryContainer').show();
$('#exStudentInfoContainer').hide();
} else if ($(this).val() === 'Ex-Student') {
$('#exStudentInfoContainer').show();
$('#staffDepartmentContainer').hide();
$('#staffCategoryContainer').hide();
} else {
$('#staffDepartmentContainer').hide();
$('#staffCategoryContainer').hide();
$('#exStudentInfoContainer').hide();
}
});
$('#religion').on('change', function () {
if ($(this).val() === 'Christian') {
$('#denominationContainer').show();
$('#churchContainer').show();
} else {
$('#denominationContainer').hide();
$('#churchContainer').hide();
}
});
$('#fatherReligion').on('change', function () {
if ($(this).val() === 'Christian') {
$('#fatherDenominationContainer').show();
$('#fatherChurchContainer').show();
} else {
$('#fatherDenominationContainer').hide();
$('#fatherChurchContainer').hide();
}
});
$('#motherReligion').on('change', function () {
if ($(this).val() === 'Christian') {
$('#motherDenominationContainer').show();
$('#motherChurchContainer').show();
} else {
$('#motherDenominationContainer').hide();
$('#motherChurchContainer').hide();
}
});
function readURL(input, previewId) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$(previewId).attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
// Bind change events to file inputs for image preview
$('input[name="candidateImage"]').change(function () {
readURL(this, '#candidateImage');
});
$('input[name="fatherImage"]').change(function () {
readURL(this, '#fatherImage');
});
$('input[name="motherImage"]').change(function () {
readURL(this, '#motherImage');
});
$.validator.addMethod(
'regex',
function (value, element, regexpr) {
if (value == '') {
return true;
}
return regexpr.test(value);
},
'Please check your input'
);
$.validator.addMethod(
'extension',
function (value, element, param) {
let fileExtension = value.split('.').pop().toLowerCase();
return this.optional(element) || param.includes(fileExtension);
},
'Please upload a file with a valid extension'
);
$.validator.addMethod(
'fileSize',
function (value, element, param) {
if (element.files.length === 0) {
return true; // No file selected
}
var fileSize = element.files[0].size;
return this.optional(element) || fileSize <= param;
},
'Please upload a file smaller than the specified size'
);
$('#application-form').validate({
rules: {
formSubmitCheck: 'required',
},
messages: {
formSubmitCheck: 'Please check this box to submit the form',
},
errorPlacement: function (error, element) {
element.prev('label').addClass('is-invalid');
element.next('.la-invalid-feedback').html(error.html());
},
highlight: function (element) {
$(element).addClass('is-invalid');
},
unhighlight: function (element) {
$(element).removeClass('is-invalid');
$(element).prev('label').removeClass('is-invalid');
$(element).next('.la-invalid-feedback').html('');
},
submitHandler: function (form) {
var formData = new FormData(form);
let jsonData = {};
$('#duplicateFatherEmail').each(function () {
formData.set('duplicateFatherEmail', this.checked);
});
//TODO: validate the form for custom validations
let reconfiguredFormData = reconfigureFormData(formData);
if (!reconfiguredFormData) {
return false;
}
$('.loader').css('display', 'inline-block');
$('.btn-text').css('display', 'none');
$('#btn-sumbit').prop('disabled', true);
$.ajax({
// TODO: move the url to a constant file
url: BASE_URL_LAMARTIN + '/admission-form/admin-submit',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function (response) {
formData.forEach((value, key) => {
jsonData[key] = value;
});
sessionStorage.setItem('userData', JSON.stringify(jsonData));
window.location.href = 'success.html';
},
error: function (xhr, status, error) {
$('.loader').css('display', 'none');
$('.btn-text').css('display', 'inline-block');
$('#btn-sumbit').prop('disabled', false);
if (xhr.responseText) {
console.log(xhr.responseText);
console.log(JSON.parse(xhr.responseText).message);
var errorMessage = JSON.parse(xhr.responseText).message;
$('#messageModal .modal-title').text('Error');
$('#messageModal .modal-body').text(JSON.parse(xhr.responseText).message);
$('#messageModal').modal('show');
} else {
$('#messageModal .modal-title').html('Error');
$('#messageModal .modal-body').html('No response from server');
$('#messageModal').modal('show');
}
},
});
return false;
},
});
function reconfigureFormData(formData) {
let reconfiguredFormData = new FormData();
reconfiguredFormData = formData;
var errorElements = [];
// conditional validation on category
if (!formData.get('correspondenceAddress')) {
let correspondenceAddress = formData.get('homeAddress');
reconfiguredFormData.set('correspondenceAddress', correspondenceAddress);
}
if (formData.get('category') === 'Staff Child') {
//TODO: add validation for staff
reconfiguredFormData.set('exStudentInfo', '');
}
else if (formData.get('category') === 'Ex-Student') {
//TODO: add validation for ex-student
reconfiguredFormData.set('staffDepartment', '');
reconfiguredFormData.set('staffCategory', '');
} else {
reconfiguredFormData.set('staffDepartment', '');
reconfiguredFormData.set('staffCategory', '');
reconfiguredFormData.set('exStudentInfo', '');
}
// conditional validation on candidate religion
if (formData.get('religion') === 'Christian') {
//TODO: add validation for denomination and church
} else {
reconfiguredFormData.set('denomination', '');
reconfiguredFormData.set('church', '');
}
// conditional validation on candidate father's religion
if (formData.get('fatherReligion') === 'Christian') {
//TODO: add validation for father's denomination and church
} else {
reconfiguredFormData.set('fatherDenomination', '');
reconfiguredFormData.set('fatherChurch', '');
}
// conditional validation on candidate mother's religion
if (formData.get('motherReligion') === 'Christian') {
//TODO: add validation for mother's denomination and church
} else {
reconfiguredFormData.set('motherDenomination', '');
reconfiguredFormData.set('motherChurch', '');
}
if (errorElements.length > 0) {
$('html, body').animate({
scrollTop: $(errorElements[0]).offset().top - 100
}, 200);
return null;
}
return reconfigureFormData;
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment