Commit e25e0439 authored by Deep Dey's avatar Deep Dey

chore: update form validation for married parents

parent e6c408e1
......@@ -175,6 +175,7 @@
<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 -->
......@@ -275,22 +276,22 @@
<h4>DETAILS OF MOTHER</h4>
<div class="la-form-group">
<label for="motherName">Full Name <span>*</span></label>
<input type="text" name="motherName" class="la-form-control">
<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</label>
<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</label>
<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 type="text" name="motherNationality" class="la-form-control">
<input id="motherNationality" type="text" name="motherNationality" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
......@@ -319,19 +320,19 @@
</div>
<div class="la-form-group">
<label for="motherMotherTongue">Mother Tongue <span>*</span></label>
<input type="text" name="motherMotherTongue" class="la-form-control">
<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 type="text" name="motherCommunity" class="la-form-control">
<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 type="text" name="motherSchoolInfo" class="la-form-control">
<input id="motherSchoolInfo" type="text" name="motherSchoolInfo" class="la-form-control">
<div class="la-invalid-feedback"></div>
</div>
<div class="la-form-group">
......@@ -351,7 +352,7 @@
</div>
<div class="la-form-group">
<label for="motherOccupation">Occupation and Designation <span>*</span></label>
<input type="text" name="motherOccupation" class="la-form-control">
<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>
......@@ -373,23 +374,28 @@
<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"></div>
<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"></div>
<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"></div>
<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" value="" id="formSubmitCheck">
<label class="form-check-label text-justify" for="flexCheckDefault">
Before submitting the form, Please 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>
......
......@@ -170,16 +170,6 @@ $(document).ready(function () {
fatherSchoolInfo: 'required',
fatherOccupation: 'required',
fatherMonthlyIncome: 'required',
motherName: 'required',
motherMobile: {
regex: /^[0-9]{10}$/,
},
motherNationality: 'required',
motherReligion: 'required',
motherMotherTongue: 'required',
motherCommunity: 'required',
motherSchoolInfo: 'required',
motherOccupation: 'required',
candidateImage: {
required: true,
extension: ['jpg', 'png', 'jpeg', 'svg'],
......@@ -190,11 +180,7 @@ $(document).ready(function () {
extension: ['jpg', 'png', 'jpeg', 'svg'],
fileSize: 1 * 1024 * 1024,
},
// motherImage: {
// required: true,
// extension: ['jpg', 'png', 'jpeg', 'svg'],
// fileSize: 1 * 1024 * 1024,
// },
formSubmitCheck: 'required',
},
messages: {
school: 'Please select your school',
......@@ -222,16 +208,6 @@ $(document).ready(function () {
fatherSchoolInfo: "Please enter father's school name",
fatherOccupation: "Please enter father's occupation",
fatherMonthlyIncome: "Please enter father's monthly income",
motherName: "Please enter mother's name",
motherMobile: {
regex: 'Please enter a valid phone number',
},
motherNationality: "Please enter mother's nationality",
motherReligion: "Please enter mother's religion",
motherMotherTongue: "Please enter mother's mother tongue",
motherCommunity: "Please specify mother's community",
motherSchoolInfo: "Please enter mother's school name",
motherOccupation: "Please enter mother's occupation",
candidateImage: {
required: "Candidate's photo is required",
extension: 'Only jpg, jpeg, png, svg files are allowed.',
......@@ -242,11 +218,7 @@ $(document).ready(function () {
extension: 'Only jpg, jpeg, png, svg files are allowed.',
fileSize: 'Please upload a file smaller than 1 MB',
},
motherImage: {
required: "Mother's photo is required",
extension: 'Only jpg, jpeg, png, svg files are allowed.',
fileSize: 'Please upload a file smaller than 1 MB',
},
formSubmitCheck: 'Please check this box to submit the form',
},
errorPlacement: function (error, element) {
element.prev('label').addClass('is-invalid');
......@@ -420,6 +392,14 @@ $(document).ready(function () {
}
if (formData.get('maritalStatus') === 'Married') {
if (!formData.get('motherName')) {
$('#motherName').addClass('is-invalid');
$('#motherName').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother name');
$('#motherName').prev('label').addClass('is-invalid');
errorElements.push('#motherName');
}
if (!formData.get('motherEmail')) {
$('#motherEmail').addClass('is-invalid');
$('#motherEmail').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother email');
......@@ -427,16 +407,69 @@ $(document).ready(function () {
errorElements.push('#motherEmail');
}
if (!formData.get('motherMobile')) {
if (
!formData.get('motherMobile') ||
!formData.get('motherMobile').match(/^[0-9]{10}$/)
) {
$('#motherMobile').addClass('is-invalid');
$('#motherMobile').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother mobile');
$('#motherMobile').prev('label').addClass('is-invalid');
errorElements.push('#motherMobile');
}
if (formData.get('motherImage').name == '') {
if (!formData.get('motherNationality')) {
$('#motherNationality').addClass('is-invalid');
$('#motherNationality').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother nationality');
$('#motherNationality').prev('label').addClass('is-invalid');
errorElements.push('#motherNationality');
}
if (!formData.get('motherReligion')) {
$('#motherReligion').addClass('is-invalid');
$('#motherReligion').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother religion');
$('#motherReligion').prev('label').addClass('is-invalid');
errorElements.push('#motherReligion');
}
if (!formData.get('motherMotherTongue')) {
$('#motherMotherTongue').addClass('is-invalid');
$('#motherMotherTongue').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother mother tongue');
$('#motherMotherTongue').prev('label').addClass('is-invalid');
errorElements.push('#motherMotherTongue');
}
if (!formData.get('motherCommunity')) {
$('#motherCommunity').addClass('is-invalid');
$('#motherCommunity').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother community');
$('#motherCommunity').prev('label').addClass('is-invalid');
errorElements.push('#motherCommunity');
}
if (!formData.get('motherSchoolInfo')) {
$('#motherSchoolInfo').addClass('is-invalid');
$('#motherSchoolInfo').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother school name');
$('#motherSchoolInfo').prev('label').addClass('is-invalid');
errorElements.push('#motherSchoolInfo');
}
if (formData.get('motherOccupation') === '') {
$('#motherOccupation').addClass('is-invalid');
$('#motherOccupation').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother occupation');
$('#motherOccupation').prev('label').addClass('is-invalid');
errorElements.push('#motherOccupation');
}
if (
!formData.get('motherImage').name ||
!formData.get('motherImage').name.match(/.(jpg|jpeg|png|svg)$/i)
) {
$('#motherImageInput').addClass('is-invalid');
$('#motherImageInput').next('.la-invalid-feedback').html('For Marital Status Married, Mother image mandatory with format jpg, jpeg, png, svg');
$('#motherImageInput').prev('label').addClass('is-invalid');
errorElements.push('#motherImageInput');
} else if (formData.get('motherImage').size > 1 * 1024 * 1024) {
$('#motherImageInput').addClass('is-invalid');
$('#motherImageInput').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother image');
$('#motherImageInput').next('.la-invalid-feedback').html('Mother image size must be less than 1 MB');
$('#motherImageInput').prev('label').addClass('is-invalid');
errorElements.push('#motherImageInput');
}
......
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