Team 3 (Phone Validation)

This commit is contained in:
zeeshan 2026-07-06 14:47:00 +05:30
parent 1843f6f126
commit 3c6cecafb5
1 changed files with 23 additions and 4 deletions

View File

@ -168,7 +168,7 @@
</div>
@if($question->code == 'phone_no_staff')
<h5>
<h5 class="text-center">
Enter No. of Units per Respule for the Brand Order Received
</h5>
@endif
@ -224,15 +224,28 @@
$(this).val($(this).val().replace(/[^a-zA-Z\s]/g, ''));
});
$('#field-phone_no_staff').on('input', function () {
/* $('#field-phone_no_staff').on('input', function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
// First digit must be 6,7,8,9
if (this.value.length > 0 && !/^[6-9]/.test(this.value)) {
this.value = '';
}
}); */
$('#field-phone_no_staff').on('input', function () {
// Allow only digits and max 10 digits
this.value = this.value.replace(/\D/g, '').slice(0, 10);
// First digit must be 6, 7, 8, or 9
if (this.value.length > 0 && !/^[6-9]/.test(this.value)) {
alert("Phone number must start with 6, 7, 8, or 9.");
this.value = '';
$(this).focus();
}
});
$('#field-budecort_respule, #field-duolin_respule, #field-levolin_respule, #field-hyperneb_respule, #field-budesal_respule').on('input', function () {
$('#field-budecort_respule, #field-duolin_respule, #field-levolin_respule, #field-input_given_count, #field-hyperneb_respule, #field-budesal_respule').on('input', function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
@ -291,6 +304,12 @@
}
});
/* $('#field-input_name,#field-input_given_count').on('change',function(){
$('#report-form input.dynamic-hidden').remove();
$('#report-form').append('<input type="hidden" class="dynamic-hidden" name="'+ $('#field-input_name').val() +'" value="1">')
}) */
$('#field-user_id').change(function(){
let hierarchy = $('option:selected', this).attr('hierarchy');
$('#field-hierarchy_id').val(hierarchy)
@ -316,7 +335,7 @@
$('#report-form').on('submit', function(event){
event.preventDefault();
let mobile = $('#field-phone_no_staff').val().trim();
$('#report-form').append('<input type="hidden" name="'+ $('#field-input_name').val() +'_pob_units" value="'+ $("#field-input_given_count").val() +'">')
if (!/^[6-9]\d{9}$/.test(mobile)) {
Swal.fire({
icon: 'error',