FIX_POS
This commit is contained in:
parent
ca7dca8575
commit
c6d39cb353
@ -128,10 +128,12 @@
|
|||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="email">Email<span class="text-danger">*</span></label>
|
<label for="email">Email<span class="text-danger">*</span></label>
|
||||||
<input type="email" class="form-control" id="email" name="email" placeholder="Enter Email" required data-parsley-type="email" data-parsley-trigger="keyup">
|
<input type="email" class="form-control" id="email" name="email" placeholder="Enter Email" required data-parsley-type="email" data-parsley-trigger="keyup">
|
||||||
|
<small id="email_error" class="text-danger d-none"></small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="mobile">Mobile<span class="text-danger">*</span></label>
|
<label for="mobile">Mobile<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="mobile" name="mobile" placeholder="Enter Mobile" required data-parsley-pattern="^[6-9]\d{9}$" data-parsley-trigger="keyup" data-parsley-length="[10,10]" data-parsley-validation-threshold="10" data-parsley-length-message="Mobile number must be 10 digits." data-parsley-pattern-message="Please enter a valid 10-digit mobile number starting with 6, 7, 8, or 9.">
|
<input type="text" class="form-control" id="mobile" name="mobile" placeholder="Enter Mobile" maxlength="10" inputmode="numeric" pattern="[0-9]{10}" required>
|
||||||
|
<small id="mobile_error" class="text-danger d-none"></small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -173,7 +175,7 @@
|
|||||||
<input type="file" class="form-control" name="aadhar_file_name" id="aadhar_file_name" accept=".pdf,.jpg,.jpeg,.png" data-parsley-file-validation>
|
<input type="file" class="form-control" name="aadhar_file_name" id="aadhar_file_name" accept=".pdf,.jpg,.jpeg,.png" data-parsley-file-validation>
|
||||||
<i class="mdi mdi-upload additional-icon"></i>
|
<i class="mdi mdi-upload additional-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
<small class="text-muted d-block">Allowed: PDF, XLSX, XLS, PNG, JPG, JPEG. <= Default</small>
|
<small class="text-muted d-block">Allowed: PDF, PNG, JPG, JPEG.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="pan_file_name">PAN</label>
|
<label for="pan_file_name">PAN</label>
|
||||||
@ -181,7 +183,7 @@
|
|||||||
<input type="file" class="form-control" name="pan_file_name" id="pan_file_name" accept=".pdf,.jpg,.jpeg,.png" data-parsley-file-validation>
|
<input type="file" class="form-control" name="pan_file_name" id="pan_file_name" accept=".pdf,.jpg,.jpeg,.png" data-parsley-file-validation>
|
||||||
<i class="mdi mdi-upload additional-icon"></i>
|
<i class="mdi mdi-upload additional-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
<small class="text-muted d-block">Allowed: PDF, XLSX, XLS, PNG, JPG, JPEG. <= Default</small>
|
<small class="text-muted d-block">Allowed: PDF, PNG, JPG, JPEG.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="certificate_file_name">Certificate</label>
|
<label for="certificate_file_name">Certificate</label>
|
||||||
@ -189,7 +191,7 @@
|
|||||||
<input type="file" class="form-control" name="certificate_file_name" id="certificate_file_name" accept=".pdf,.jpg,.jpeg,.png" data-parsley-file-validation>
|
<input type="file" class="form-control" name="certificate_file_name" id="certificate_file_name" accept=".pdf,.jpg,.jpeg,.png" data-parsley-file-validation>
|
||||||
<i class="mdi mdi-upload additional-icon"></i>
|
<i class="mdi mdi-upload additional-icon"></i>
|
||||||
</div>
|
</div>
|
||||||
<small class="text-muted d-block">Allowed: PDF, XLSX, XLS, PNG, JPG, JPEG. <= Default</small>
|
<small class="text-muted d-block">Allowed: PDF, PNG, JPG, JPEG.</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -227,41 +229,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Parsley custom validator for file type and size
|
|
||||||
window.Parsley.addValidator('fileValidation', {
|
|
||||||
requirementType: 'string',
|
|
||||||
validateString: function(value, requirement, parsleyInstance) {
|
|
||||||
const file = parsleyInstance.$element[0].files[0];
|
|
||||||
if (!file) {
|
|
||||||
return true; // Skip validation if no file is selected (unless 'required' is also present)
|
|
||||||
}
|
|
||||||
|
|
||||||
const maxImageSize = 500 * 1024; // 500KB
|
|
||||||
const maxPdfSize = 25 * 1024 * 1024; // 25MB
|
|
||||||
const imageTypes = ['image/jpeg', 'image/png', 'image/jpg'];
|
|
||||||
const pdfType = 'application/pdf';
|
|
||||||
|
|
||||||
if (imageTypes.includes(file.type)) {
|
|
||||||
if (file.size > maxImageSize) {
|
|
||||||
this.errorMessage = 'Image size cannot exceed 500KB.';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (file.type === pdfType) {
|
|
||||||
if (file.size > maxPdfSize) {
|
|
||||||
this.errorMessage = 'PDF size cannot exceed 25MB.';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.errorMessage = 'Allowed file types are JPG, JPEG, PNG, and PDF.';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
messages: {
|
|
||||||
en: 'File is invalid.' // Default fallback message
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var table;
|
var table;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#manager_id').select2();
|
$('#manager_id').select2();
|
||||||
@ -493,18 +460,77 @@
|
|||||||
|
|
||||||
$('#partnerPOSForm').on('submit', function(e) {
|
$('#partnerPOSForm').on('submit', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $form = $(this);
|
const form = this;
|
||||||
|
|
||||||
// Validate the form using Parsley
|
|
||||||
$form.parsley().validate();
|
|
||||||
|
|
||||||
// Check if the form is valid
|
// HTML5 built-in validation
|
||||||
if ($form.parsley().isValid()) {
|
if (!form.checkValidity()) {
|
||||||
// If valid, submit via AJAX
|
form.reportValidity(); // shows required/pattern tooltips
|
||||||
handleSaveEditAndDelete('submit');
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom validation
|
||||||
|
if (!validateForm()) return;
|
||||||
|
|
||||||
|
// If valid, submit via AJAX
|
||||||
|
handleSaveEditAndDelete('submit');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function validateForm() {
|
||||||
|
let isValid = true;
|
||||||
|
|
||||||
|
// Clear old errors
|
||||||
|
$('.text-danger').addClass('d-none').text('');
|
||||||
|
|
||||||
|
// Regex patterns
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
const mobileRegex = /^[6-9]\d{9}$/;
|
||||||
|
const aadharRegex = /^\d{12}$/;
|
||||||
|
const panRegex = /^[A-Z]{5}[0-9]{4}[A-Z]$/;
|
||||||
|
|
||||||
|
// EMAIL
|
||||||
|
const email = $('#email').val().trim();
|
||||||
|
if (email === '') {
|
||||||
|
$('#email_error').text('Email is required').removeClass('d-none');
|
||||||
|
isValid = false;
|
||||||
|
} else if (!emailRegex.test(email)) {
|
||||||
|
$('#email_error').text('Enter a valid email').removeClass('d-none');
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MOBILE
|
||||||
|
const mobile = $('#mobile').val().trim();
|
||||||
|
if (mobile === '') {
|
||||||
|
$('#mobile_error').text('Mobile number is required').removeClass('d-none');
|
||||||
|
isValid = false;
|
||||||
|
} else if (!mobileRegex.test(mobile)) {
|
||||||
|
$('#mobile_error').text('Enter a valid 10-digit mobile number').removeClass('d-none');
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AADHAAR
|
||||||
|
const aadhar = $('#aadhar').val().trim();
|
||||||
|
if (aadhar === '') {
|
||||||
|
$('#aadhar_error').text('Aadhaar is required').removeClass('d-none');
|
||||||
|
isValid = false;
|
||||||
|
} else if (!aadharRegex.test(aadhar)) {
|
||||||
|
$('#aadhar_error').text('Aadhaar must be 12 digits').removeClass('d-none');
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PAN
|
||||||
|
const pan = $('#pan').val().trim();
|
||||||
|
if (pan === '') {
|
||||||
|
$('#pan_error').text('PAN is required').removeClass('d-none');
|
||||||
|
isValid = false;
|
||||||
|
} else if (!panRegex.test(pan)) {
|
||||||
|
$('#pan_error').text('Invalid PAN format (AAAPA1234A)').removeClass('d-none');
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
@ -594,5 +620,4 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
</script>
|
||||||
</script>
|
|
||||||
Loading…
Reference in New Issue
Block a user