Commit e25e0439 authored by Deep Dey's avatar Deep Dey

chore: update form validation for married parents

parent e6c408e1
...@@ -175,6 +175,7 @@ ...@@ -175,6 +175,7 @@
<option value="Single">Single</option> <option value="Single">Single</option>
</select> </select>
<div class="la-invalid-feedback"></div> <div class="la-invalid-feedback"></div>
<small>Mother information is mandatory for <b>Married</b></small>
</div> </div>
<!-- Father Information --> <!-- Father Information -->
...@@ -275,22 +276,22 @@ ...@@ -275,22 +276,22 @@
<h4>DETAILS OF MOTHER</h4> <h4>DETAILS OF MOTHER</h4>
<div class="la-form-group"> <div class="la-form-group">
<label for="motherName">Full Name <span>*</span></label> <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 class="la-invalid-feedback"></div>
</div> </div>
<div class="la-form-group"> <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"> <input id="motherEmail" type="email" name="motherEmail" class="la-form-control">
<div class="la-invalid-feedback"></div> <div class="la-invalid-feedback"></div>
</div> </div>
<div class="la-form-group"> <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"> <input id="motherMobile" type="text" name="motherMobile" class="la-form-control">
<div class="la-invalid-feedback"></div> <div class="la-invalid-feedback"></div>
</div> </div>
<div class="la-form-group"> <div class="la-form-group">
<label for="motherNationality">Nationality <span>*</span></label> <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 class="la-invalid-feedback"></div>
</div> </div>
<div class="la-form-group"> <div class="la-form-group">
...@@ -319,19 +320,19 @@ ...@@ -319,19 +320,19 @@
</div> </div>
<div class="la-form-group"> <div class="la-form-group">
<label for="motherMotherTongue">Mother Tongue <span>*</span></label> <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 class="la-invalid-feedback"></div>
</div> </div>
<div class="la-form-group"> <div class="la-form-group">
<label for="motherCommunity">Community <span>*</span></label> <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> <div class="la-invalid-feedback"></div>
<small>Socio- Linguistic community (eg Bengali, Punjabi, Marwari, Jain etc.)</small> <small>Socio- Linguistic community (eg Bengali, Punjabi, Marwari, Jain etc.)</small>
</div> </div>
<div class="la-form-group"> <div class="la-form-group">
<label for="motherSchoolInfo">School, Name of Institution, Examination <label for="motherSchoolInfo">School, Name of Institution, Examination
Passed <span>*</span></label> 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 class="la-invalid-feedback"></div>
</div> </div>
<div class="la-form-group"> <div class="la-form-group">
...@@ -351,7 +352,7 @@ ...@@ -351,7 +352,7 @@
</div> </div>
<div class="la-form-group"> <div class="la-form-group">
<label for="motherOccupation">Occupation and Designation <span>*</span></label> <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> <div class="la-invalid-feedback"></div>
<small>If not working please write Homemaker/Housewife</small> <small>If not working please write Homemaker/Housewife</small>
</div> </div>
...@@ -373,23 +374,28 @@ ...@@ -373,23 +374,28 @@
<img id="candidateImage" class="image-preview" src="./img/candidate.png" alt="candidate photo"> <img id="candidateImage" class="image-preview" src="./img/candidate.png" alt="candidate photo">
<label for="candidateImage">Candidate's Photo</label> <label for="candidateImage">Candidate's Photo</label>
<input type="file" name="candidateImage" class="la-form-control"> <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>
<div class="la-form-group"> <div class="la-form-group">
<img id="fatherImage" class="image-preview" src="./img/father.png" alt="father photo"> <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> <label for="fatherImage" style="text-align: center;">Father's/Guardian's Photo</label>
<input type="file" name="fatherImage" class="la-form-control"> <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>
<div class="la-form-group"> <div class="la-form-group">
<img id="motherImage" class="image-preview" src="./img/mother.png" alt="mother photo"> <img id="motherImage" class="image-preview" src="./img/mother.png" alt="mother photo">
<label for="motherImage">Mother's Photo</label> <label for="motherImage">Mother's Photo</label>
<input id="motherImageInput" type="file" name="motherImage" class="la-form-control"> <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>
</div> </div>
<!-- end of image section --> <!-- 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"> <div class="form-btn">
<button type="submit" class="btn btn-sumbit" id="btn-sumbit"> <button type="submit" class="btn btn-sumbit" id="btn-sumbit">
<div class="loader"></div> <div class="loader"></div>
......
...@@ -170,16 +170,6 @@ $(document).ready(function () { ...@@ -170,16 +170,6 @@ $(document).ready(function () {
fatherSchoolInfo: 'required', fatherSchoolInfo: 'required',
fatherOccupation: 'required', fatherOccupation: 'required',
fatherMonthlyIncome: 'required', fatherMonthlyIncome: 'required',
motherName: 'required',
motherMobile: {
regex: /^[0-9]{10}$/,
},
motherNationality: 'required',
motherReligion: 'required',
motherMotherTongue: 'required',
motherCommunity: 'required',
motherSchoolInfo: 'required',
motherOccupation: 'required',
candidateImage: { candidateImage: {
required: true, required: true,
extension: ['jpg', 'png', 'jpeg', 'svg'], extension: ['jpg', 'png', 'jpeg', 'svg'],
...@@ -190,11 +180,7 @@ $(document).ready(function () { ...@@ -190,11 +180,7 @@ $(document).ready(function () {
extension: ['jpg', 'png', 'jpeg', 'svg'], extension: ['jpg', 'png', 'jpeg', 'svg'],
fileSize: 1 * 1024 * 1024, fileSize: 1 * 1024 * 1024,
}, },
// motherImage: { formSubmitCheck: 'required',
// required: true,
// extension: ['jpg', 'png', 'jpeg', 'svg'],
// fileSize: 1 * 1024 * 1024,
// },
}, },
messages: { messages: {
school: 'Please select your school', school: 'Please select your school',
...@@ -222,16 +208,6 @@ $(document).ready(function () { ...@@ -222,16 +208,6 @@ $(document).ready(function () {
fatherSchoolInfo: "Please enter father's school name", fatherSchoolInfo: "Please enter father's school name",
fatherOccupation: "Please enter father's occupation", fatherOccupation: "Please enter father's occupation",
fatherMonthlyIncome: "Please enter father's monthly income", 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: { candidateImage: {
required: "Candidate's photo is required", required: "Candidate's photo is required",
extension: 'Only jpg, jpeg, png, svg files are allowed.', extension: 'Only jpg, jpeg, png, svg files are allowed.',
...@@ -242,11 +218,7 @@ $(document).ready(function () { ...@@ -242,11 +218,7 @@ $(document).ready(function () {
extension: 'Only jpg, jpeg, png, svg files are allowed.', extension: 'Only jpg, jpeg, png, svg files are allowed.',
fileSize: 'Please upload a file smaller than 1 MB', fileSize: 'Please upload a file smaller than 1 MB',
}, },
motherImage: { formSubmitCheck: 'Please check this box to submit the form',
required: "Mother's photo is required",
extension: 'Only jpg, jpeg, png, svg files are allowed.',
fileSize: 'Please upload a file smaller than 1 MB',
},
}, },
errorPlacement: function (error, element) { errorPlacement: function (error, element) {
element.prev('label').addClass('is-invalid'); element.prev('label').addClass('is-invalid');
...@@ -420,6 +392,14 @@ $(document).ready(function () { ...@@ -420,6 +392,14 @@ $(document).ready(function () {
} }
if (formData.get('maritalStatus') === 'Married') { 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')) { if (!formData.get('motherEmail')) {
$('#motherEmail').addClass('is-invalid'); $('#motherEmail').addClass('is-invalid');
$('#motherEmail').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother email'); $('#motherEmail').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother email');
...@@ -427,16 +407,69 @@ $(document).ready(function () { ...@@ -427,16 +407,69 @@ $(document).ready(function () {
errorElements.push('#motherEmail'); errorElements.push('#motherEmail');
} }
if (!formData.get('motherMobile')) { if (
!formData.get('motherMobile') ||
!formData.get('motherMobile').match(/^[0-9]{10}$/)
) {
$('#motherMobile').addClass('is-invalid'); $('#motherMobile').addClass('is-invalid');
$('#motherMobile').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother mobile'); $('#motherMobile').next('.la-invalid-feedback').html('For Marital Status Married, Please provide mother mobile');
$('#motherMobile').prev('label').addClass('is-invalid'); $('#motherMobile').prev('label').addClass('is-invalid');
errorElements.push('#motherMobile'); 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').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'); $('#motherImageInput').prev('label').addClass('is-invalid');
errorElements.push('#motherImageInput'); 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