Team4 New Form : MONTAIR LC KID 5 - CHEMIST & DR TAGGING added validation
Specific Folder FTP Upload / ftp-deploy (push) Successful in 48s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 48s
Details
This commit is contained in:
parent
150a86f3b5
commit
fb26492066
|
|
@ -353,29 +353,83 @@
|
||||||
|
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
// CHEMIST PHONE NUMBER VALIDATION
|
// CHEMIST PHONE NUMBER VALIDATION
|
||||||
// Starts with 6-9
|
// Exactly 10 digits
|
||||||
|
// Starts from 6-9
|
||||||
|
// ==========================================
|
||||||
|
|
||||||
|
$(document).on(
|
||||||
|
'input',
|
||||||
|
'input[id^="field-chemist_"][id*="_number"]',
|
||||||
|
function () {
|
||||||
|
|
||||||
|
// Allow digits only
|
||||||
|
this.value = this.value.replace(/[^0-9]/g, '');
|
||||||
|
|
||||||
// Maximum 10 digits
|
// Maximum 10 digits
|
||||||
// No negative, decimal or special characters
|
this.value = this.value.substring(0, 10);
|
||||||
// Works for initial + dynamically added wrappers
|
|
||||||
// ==========================================
|
|
||||||
$(document).on(
|
|
||||||
'input',
|
|
||||||
'input[id^="field-chemist_"][id*="_number"]',
|
|
||||||
function () {
|
|
||||||
|
|
||||||
// Allow digits only
|
// First digit must be 6-9
|
||||||
this.value = this.value.replace(/[^0-9]/g, '');
|
if (
|
||||||
|
this.value.length > 0 &&
|
||||||
|
!/^[6-9]/.test(this.value)
|
||||||
|
) {
|
||||||
|
|
||||||
// Maximum 10 digits
|
// Clear invalid value
|
||||||
this.value = this.value.substring(0, 10);
|
this.value = '';
|
||||||
|
|
||||||
// First digit must be 6-9
|
// Show popup only once
|
||||||
if (this.value.length > 0 && !/^[6-9]/.test(this.value)) {
|
if (!$(this).data('invalid-start-shown')) {
|
||||||
this.value = '';
|
|
||||||
}
|
$(this).data('invalid-start-shown', true);
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'warning',
|
||||||
|
title: 'Invalid Mobile Number',
|
||||||
|
text: 'Please enter a mobile number starting from 6-9.',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
}).then(() => {
|
||||||
|
// Allow popup again if user enters another invalid value
|
||||||
|
$(this).removeData('invalid-start-shown');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// EXACTLY 10 DIGITS VALIDATION
|
||||||
|
// ==========================================
|
||||||
|
|
||||||
|
$(document).on(
|
||||||
|
'blur',
|
||||||
|
'input[id^="field-chemist_"][id*="_number"]',
|
||||||
|
function () {
|
||||||
|
|
||||||
|
var mobileNumber = this.value.trim();
|
||||||
|
|
||||||
|
// Empty field - let required validation handle it
|
||||||
|
if (mobileNumber === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Must be exactly 10 digits and start with 6-9
|
||||||
|
if (!/^[6-9][0-9]{9}$/.test(mobileNumber)) {
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'warning',
|
||||||
|
title: 'Invalid Mobile Number',
|
||||||
|
text: 'Please enter a valid 10-digit mobile number.',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
});
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// Do NOT use this.focus()
|
||||||
|
// Otherwise Swal + blur can create a popup loop.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// If an old/future date is already populated, clear it
|
// If an old/future date is already populated, clear it
|
||||||
if ($('#field-record_date').val() !== today) {
|
if ($('#field-record_date').val() !== today) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue