PageSourceSearch

https://hrone.cloud/wp-content/themes/hrone-child/assets/js/custom-script.js?ver=551290860

js hrone.cloud collected 2026-09-24 10:24:38 UTC 70,687 bytes, 1,959 lines download raw bytes

1var maxWidth = 100; // Adjust as needed
2var maxHeight = 100;
3
4var companyLogoBase64 = '';
5var letterHeadBase64 = '';
6
7var loadFile = function (event) {
8
9    var output = document.getElementById('complany_logo');
10    var outputimage = document.getElementById('logo');
11    var file = event.target.files[0];
12
13    if (!file) return false;
14
15    var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/webp'];
16
17    if (!allowedTypes.includes(file.type.toLowerCase())) {
18        alert('Invalid file type! Please upload only PNG, JPEG, or WebP images.');
19        outputimage.value = '';
20        return false;
21    }
22
23    if (file.size > (1 * 1024 * 1024)) {
24        alert('File size exceeds the limit of 1 MB.');
25        outputimage.value = '';
26        return false;
27    }
28
29    var reader = new FileReader();
30
31    reader.onload = function (e) {
32
33        companyLogoBase64 = e.target.result;
34
35        output.src = companyLogoBase64;
36
37        $('.selected-image').text(file.name);
38
39    };
40
41    reader.readAsDataURL(file);
42};
43var loadHeadFile = function (event) {
44
45    var output = document.getElementById('letter_head_img');
46    var file = event.target.files[0];
47
48    if (!file) return false;
49
50    var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/webp'];
51
52    if (!allowedTypes.includes(file.type.toLowerCase())) {
53        alert('Invalid file type! Please upload only PNG, JPEG, or WebP images.');
54        event.target.value = '';
55        return false;
56    }
57
58    if (file.size > (1 * 1024 * 1024)) {
59        alert('File size exceeds the limit of 1 MB.');
60        event.target.value = '';
61        return false;
62    }
63
64    var reader = new FileReader();
65
66    reader.onload = function (e) {
67
68        letterHeadBase64 = e.target.result;
69
70        output.src = letterHeadBase64;
71
72    };
73
74    reader.readAsDataURL(file);
75};
76
77
78$(document).ready(function () {
79    $(".datepicker").datepicker({
80        onSelect: function () {
81            var inputId = $(this).attr("id");
82            // console.log(inputId.replace('_', ''));
83            $("." + inputId.replace('_', '')).text($(this).val());
84
85        }
86    });
87    $(".form-control").keyup(function () {
88        var inputId = $(this).attr("id");
89        $("." + inputId.replace('_', '')).text($(this).val());
90    });
91
92    $('#doc_req').select2({
93        closeOnSelect: false,
94        placeholder: "Select Documents Required for Joining",
95        allowHtml: true,
96        allowClear: true,
97        tags: true,
98        width: '100%',
99    });
100});
101
102jQuery(document).ready(function ($) {
103    $("#work_email").keyup(function () {
104        var email = $('#work_email').val();
105        var fields = email.split('@');
106        if ((fields[1] == 'gmail.com' || fields[1] == 'yopmail.com')) {
107            $('#work_email').val('');
108            $('.work_email_error').html('Please enter valid work email.');
109        } else {
110            $('.work_email_error').html('');
111        }
112    });
113
114
115    //     console.log("PDF FORM SUBMITTED");
116    //     e.preventDefault();
117    //     var formData = new FormData(this);
118    //     formData.append('action', 'custom_letter_generator');
119    //     formData.append('security', hroneAjaxSecurity.letter_generator);
120    //     $.ajax({
121    //         url: admin_url.ajaxUrl,
122    //         type: 'POST',
123    //         data: formData,
124    //         beforeSend: function () {
125    //             $("#submit-btn").html('Wait....');
126    //         },
127    //         success: function (response) {
128
129    //             if (response.success === true) {
130    //                 $("#customModal").fadeOut();
131    //                 if (response.data.pdf_base64 && response.data.pdf_filename) {
132    //                     var byteCharacters = atob(response.data.pdf_base64);
133    //                     var byteNumbers = new Array(byteCharacters.length);
134    //                     for (var i = 0; i < byteCharacters.length; i++) {
135    //                         byteNumbers[i] = byteCharacters.charCodeAt(i);
136    //                     }
137    //                     var byteArray = new Uint8Array(byteNumbers);
138    //                     var blob = new Blob([byteArray], { type: 'application/pdf' });
139    //                     var url = window.URL.createObjectURL(blob);
140    //                     var a = document.createElement('a');
141    //                     a.href = url;
142    //                     a.download = response.data.pdf_filename;
143    //                     document.body.appendChild(a);
144    //                     a.click();
145    //                     document.body.removeChild(a);
146
147    //                     window.URL.revokeObjectURL(url);
148    //                 } else if (response.data.pdf_url) {
149
150    //                     var a = document.createElement('a');
151    //                     a.href = response.data.pdf_url;
152    //                     a.download = 'generated_pdf.pdf';
153    //                     document.body.appendChild(a);
154    //                     a.click();
155    //                     document.body.removeChild(a);
156    //                 }
157
158    //                 document.getElementById('offerForm').reset();
159    //             } else {
160    //                 if (response.data == 'Image dimensions must be within 300x200 pixels.') {
161    //                     $(".pdf_for_error").html(response.data);
162    //                     $('html, body').animate({
163    //                         scrollTop: ($('.pdf_for_error').offset().top - 300)
164    //                     }, 2000);
165    //                     $("#customModal").fadeOut();
166    //                 } else {
167    //                     $("#customModal").fadeOut();
168    //                     for (var key in response.data) {
169    //                         var errorMessage = response.data[key][0];
170    //                         $("." + key).html(errorMessage);
171    //                     }
172    //                 }
173    //             }
174
175    //             $("#submit-btn").html('<i class="fa fa-download" aria-hidden="true"></i> Download');
176    //         },
177    //         cache: false,
178    //         contentType: false,
179    //         processData: false,
180    //     });
181    // });
182
183
184
185
186
187
188    // Prevent form from submitting normally (CSP compliance)
189    $("#popupDownload").on("submit", function (e) {
190        e.preventDefault();
191        return false;
192    });
193
194    $("#openModalBtn").click(function () {
195        $("#customModal").fadeIn();
196    });
197
198    $(".close").click(function () {
199        $("#customModal").fadeOut();
200        $("#partnerWPfstmodal").fadeOut();
201    });
202
203    // Close the modal if the overlay is clicked
204    $(window).click(function (e) {
205        if ($(e.target).is("#customModal")) {
206            $("#customModal").fadeOut();
207        }
208    });
209
210    // 🔓 Utility functions
211    function openModal(modalId) {
212        $(modalId).fadeIn();
213        $('body').addClass('scroll-hidden');
214    }
215
216    function closeAllModals() {
217        $('.modal').fadeOut();
218        $('body').removeClass('scroll-hidden');
219    }
220
221    $('#requestJoin').on('click', function (e) {
222        if (!e.isTrusted) return;
223        openModal('#requestJoinModel');
224    });
225
226    // ❌ One close handler ONLY
227    $('.close').on('click', function () {
228        closeAllModals();
229    });
230
231
232});
233
234// Validate Company Phone Number
235$('#company_contactno').on('input', function () {
236    var phoneNum = $(this).val();
237    // Remove non-numeric characters
238    phoneNum = phoneNum.replace(/\D/g, '');
239    // Ensure the phone number starts with 6, 7, 8, or 9
240    if (/^[6-9]/.test(phoneNum)) {
241        // Limit the phone number to 10 digits
242        phoneNum = phoneNum.slice(0, 10);
243        $(this).removeClass('error');
244        $('.phone_error').html('');
245    } else {
246        // If the number doesn't start with 6, 7, 8, or 9, clear the input
247        phoneNum = '';
248        $(this).addClass('error');
249        $('.phone_error').html('Insert valid number start from 6/7/8/9');
250
251    }
252    // Update the input value
253    $(this).val(phoneNum);
254});
255
256// Validate Phone Number
257$('#phone_number').on('input', function () {
258    var phoneNum = $('#phone_number').val();
259    phoneNum = phoneNum.replace(/\D/g, '');
260    if (/^[6-9]/.test(phoneNum)) {
261        phoneNum = phoneNum.slice(0, 10);
262        $('#phone_number').removeClass('error');
263        $('.phone_number_error').html('');
264    } else {
265        phoneNum = '';
266        $('#phone_number').addClass('error');
267        $('.phone_number_error').html('Insert valid number start from 6/7/8/9');
268
269    }
270    $('#phone_number').val(phoneNum);
271});
272
273
274$(document).ready(function () {
275    function captureAllFormData(formId) {
276        const formData = {};
277        const form = document.getElementById(formId);
278        if (form) {
279            const inputs = form.querySelectorAll('input[type="text"], input[type="email"], input[type="number"]');
280            inputs.forEach(input => {
281                formData[input.name] = input.value;
282            });
283        } else {
284            // console.error('Form not found with ID:', formId);
285        }
286        return formData;
287    }
288    var current_fs, next_fs, previous_fs; //fieldsets
289    var left, opacity, scale;
290    var animating;
291
292
293    var baseDomains = [];
294    var baseDomainsLoaded = false;
295    function loadBaseDomains() {
296        var rootUrl = WPURLS.siteurl;
297        var fileUrl = rootUrl + '/basedomain.txt';
298
299        return $.get(fileUrl).then(function (data) {
300            baseDomains = data.split('\n').map(function (domain) {
301                return domain.trim().toLowerCase();
302            });
303            baseDomainsLoaded = true;
304            $(".next-step").prop("disabled", false);
305        }).fail(function () {
306            //console.error('Failed to load base domains file.');
307        });
308    }
309    loadBaseDomains();
310    // Function to validate the email
311    function validateEmail(email) {
312        var atIndex = email.indexOf('@');
313        var dotIndex = email.lastIndexOf('.');
314        if (atIndex === -1 || dotIndex === -1 || atIndex > dotIndex) {
315            isValid = false;
316            return false;
317        }
318
319        var domain = email.slice(atIndex + 1).toLowerCase();
320
321        // List of accepted TLDs
322        var acceptedTLDs = [
323            'com', 'shop', 'life', 'us', 'ai', 'biz', 'name', 'in', 'ca', 'co.in', 'net', 'org', 'edu', 'ac.in',
324            'one', 'online', 'cloud', 'tech', 'co', 'info', 'world', 'io', 'com.au', 'au', 'eu',
325
326            // Additional commonly used TLDs
327            'me', 'app', 'dev', 'xyz', 'site', 'store', 'digital', 'media', 'live', 'news', 'club',
328            'space', 'agency', 'solutions', 'website', 'tools', 'software', 'design', 'academy', 'cafe', 'care', 'bike', 'bio',
329
330            // Additional ccTLDs and second-level ccTLDs
331            'uk', 'co.uk', 'org.uk', 'gov.uk', 'nz', 'de', 'fr', 'it', 'es', 'nl', 'ch', 'jp', 'kr', 'cn',
332            'gov.in', 'org.in', 'net.au', 'org.au'
333        ];
334        if (
335            email.trim() === '' ||
336            isNotAcceptedDomain(domain) ||
337            !validateDomainStructure(domain, acceptedTLDs) ||
338            email.includes('..')
339        ) {
340
341            return false;
342        } else {
343            return true;
344        }
345    }
346    function isNotAcceptedDomain(domain) {
347        return baseDomains.some(function (baseDomain) {
348            // Check if the domain starts with or matches the base domain
349            var domainParts = domain.split('.');
350            return domainParts[0] === baseDomain;
351        });
352    }
353
354    function validateDomainStructure(domain, acceptedTLDs) {
355        var domainRegex = /^[a-z0-9.-]+\.[a-z]{2,}$/;
356        if (!domainRegex.test(domain) || domain.includes('..')) {
357            return false;
358        }
359        // Check if TLD is in the accepted list
360        var tld = domain.split('.').pop();
361        return acceptedTLDs.indexOf(tld) !== -1;
362    }
363
364    // Function to load the base domains from the file
365    $(".next-step-PPC").click(function (e) {
366        e.preventDefault(); // Prevent form submission
367        var formId = $(this).closest("form").attr("id");
368
369        const formData = captureAllFormData(formId);
370        var current_fs = $(this).parent();
371        var next_fs = $(this).parent().next();
372        var isValid = true;
373        // Check if base domains are loaded
374        if (!baseDomainsLoaded) {
375            $('.email_error').html('Please wait while the email domains are being loaded. Try again.');
376            isValid = false;
377        }
378        // Check for empty fields and mark them with an error class
379        current_fs.find("input[type='text'], input[type='email']").each(function () {
380            if ($(this).val().trim() === '') {
381                isValid = false;
382                $(this).addClass('error');
383            } else {
384                $(this).removeClass('error');
385            }
386        });
387        // Check email validation only if the current fieldset contains email input
388        if (current_fs.find("#ppc_email").length > 0) {
389            var email = $('#ppc_email').val().trim().toLowerCase();
390            if (!validateEmail(email)) {
391                isValid = false;
392                $('.email_error').html('Invalid Email Format');
393                $('#ppc_email').addClass('error');
394
395            } else {
396                $('#ppc_email').removeClass('error');
397                $('.email_error').html('');
398            }
399        }
400        // Load the base domains before allowing any form submission
401        loadBaseDomains();
402        if (current_fs.find("#phone_ppc").length > 0) {
403            var phoneNum = $('#phone_ppc').val();
404            // Remove non-numeric characters
405            phoneNum = phoneNum.replace(/\D/g, '');
406            // Ensure the phone number starts with 6, 7, 8, or 9 and has a length of 2 to 10 digits
407            if (/^[6-9]\d{1,9}$/.test(phoneNum)) {
408                // Limit the phone number to 10 digits
409                phoneNum = phoneNum.slice(0, 10);
410                // Check if the phone number length is less than 10
411                if (phoneNum.length < 10) {
412                    $('#phone_ppc').addClass('error');
413                    isValid = false;
414                    $('.phone_error_PPC').html('Phone number must be exactly 10 digits long');
415                } else {
416                    $('#phone_ppc').removeClass('error');
417                    $('.phone_error_PPC').html('');
418                }
419            } else {
420                // If the number doesn't start with 6, 7, 8, or 9, clear the input
421                phoneNum = '';
422                isValid = false;
423                $('#phone_ppc').addClass('error');
424                $('.phone_error_PPC').html('Insert a valid number starting with 6/7/8/9');
425            }
426        }
427        var form = document.getElementById(formId);
428        var no_of_employee_exists = form.querySelector('#no_of_employee') !== null;
429        if (no_of_employee_exists) {
430            var no_of_employee_field = $('#no_of_employee');
431            if (no_of_employee_field.length > 0) {
432                var no_of_employee = no_of_employee_field.val();
433                if (!no_of_employee) {
434                    isValid = false;
435                    no_of_employee_field.addClass('error');
436                    $('.employee_error').html('Please select the number of employees.');
437                } else {
438                    no_of_employee_field.removeClass('error');
439                    $('.employee_error').html('');
440                }
441            }
442        }
443        // Proceed to the next step if all validations pass
444        if (isValid) {
445            $("#progressbar li.active").last().addClass("completed");
446            // Add Class Active
447            $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
448            var curr_val = $('#progBar').val();
449            var new_val = Number(curr_val) + 33;
450            $('#progBar').attr('value', new_val);
451            $("#progBar").css('width', new_val + '%');
452
453            // Show the next fieldset
454            next_fs.show();
455            // Hide the current fieldset with style
456            current_fs.animate({ opacity: 0 }, {
457                step: function (now) {
458                    // For making fieldset appear animation
459                    opacity = 1 - now;
460                    current_fs.css({
461                        'display': 'none',
462                        'position': 'relative'
463                    });
464                    next_fs.css({ 'opacity': opacity });
465                },
466                duration: 500
467            });
468        }
469    });
470
471    $(".next-step").click(function (e) {
472        e.preventDefault(); // Prevent form submission
473        var formId = $(this).closest("form").attr("id");
474
475        const formData = captureAllFormData(formId);
476        var current_fs = $(this).parent();
477        var next_fs = $(this).parent().next();
478        var isValid = true;
479        // Check if base domains are loaded
480        if (!baseDomainsLoaded) {
481            $('.email_error').html('Please wait while the email domains are being loaded. Try again.');
482            isValid = false;
483        }
484
485
486        current_fs.find("input[type='text']:not(#company_website), input[type='file'], input[type='email'], textarea[required]").each(function () {
487            if ($(this).val().trim() === '') {
488                isValid = false;
489                $(this).addClass('error');
490            } else {
491                $(this).removeClass('error');
492            }
493        });
494        // Validate number fields like CTC
495        current_fs.find("input[type='number']").each(function () {
496
497            const inputId = $(this).attr('id');
498            const inputValue = $(this).val().trim();
499
500            // Required number fields
501            if ($(this).prop('required') && inputValue === '') {
502                isValid = false;
503                $(this).addClass('error');
504            } else {
505                $(this).removeClass('error');
506            }
507
508            // Specific validation for CTC fields
509            if (
510                inputId === 'ctc_total' ||
511                inputId === 'ctc_fixed' ||
512                inputId === 'ctc_veri'
513            ) {
514
515                if (
516                    inputValue === '' ||
517                    isNaN(inputValue) ||
518                    Number(inputValue) <= 0
519                ) {
520                    isValid = false;
521                    $(this).addClass('error');
522                } else {
523                    $(this).removeClass('error');
524                }
525            }
526        });
527        // Check email validation only if the current fieldset contains email input
528        if (current_fs.find("#official_email").length > 0) {
529            var email = $('#official_email').val().trim().toLowerCase();
530            if (!validateEmail(email)) {
531                isValid = false;
532                $('.email_error').html('Invalid Email Format');
533                $('#official_email').addClass('error');
534
535            } else {
536                $('#official_email').removeClass('error');
537                $('.email_error').html('');
538            }
539        }
540
541        // Initially disable the next-step button
542        $(".next-step").prop("disabled", true);
543
544        // Load the base domains before allowing any form submission
545        loadBaseDomains();
546
547        if (current_fs.find("#popup_phone_nu").length > 0) {
548            var phoneNum = $('#popup_phone_nu').val();
549            // Remove non-numeric characters
550            phoneNum = phoneNum.replace(/\D/g, '');
551            // Ensure the phone number starts with 6, 7, 8, or 9 and has a length of 2 to 10 digits
552            if (/^[6-9]\d{1,9}$/.test(phoneNum)) {
553                // Limit the phone number to 10 digits
554                phoneNum = phoneNum.slice(0, 10);
555                // Check if the phone number length is less than 10
556                if (phoneNum.length < 10) {
557                    $('#popup_phone_nu').addClass('error');
558                    isValid = false;
559                    $('.popup_phone_error').html('Phone number must be exactly 10 digits long');
560                } else {
561                    $('#popup_phone_nu').removeClass('error');
562                    $('.popup_phone_error').html('');
563                }
564            } else {
565                // If the number doesn't start with 6, 7, 8, or 9, clear the input
566                phoneNum = '';
567                isValid = false;
568                $('#popup_phone_nu').addClass('error');
569                $('.popup_phone_error').html('Insert a valid number starting with 6/7/8/9');
570            }
571        }
572        var form = document.getElementById(formId);
573        var phoneNuElement = form.querySelector('#phone_nu');
574        if (phoneNuElement !== null) {
575            var phoneNum = $('#phone_nu').val();
576            // Remove non-numeric characters
577            phoneNum = phoneNum.replace(/\D/g, '');
578            // Ensure the phone number starts with 6, 7, 8, or 9 and has a length of 10 digits
579            if (/^[6-9]\d{9}$/.test(phoneNum)) {
580                // Limit the phone number to 10 digits
581                phoneNum = phoneNum.slice(0, 10);
582                $('#phone_nu').removeClass('error');
583                $('.phone_error').html('');
584            } else {
585                $('#phone_nu').addClass('error');
586                isValid = false;
587                if (phoneNum.length < 10) {
588                    $('.phone_error').html('Phone number must be exactly 10 digits long');
589                } else {
590                    $('.phone_error').html('Insert a valid number starting with 6/7/8/9');
591                }
592            }
593        }
594
595        // Check email validation only if the current fieldset contains email input
596        if (current_fs.find("#popup_official_email").length > 0) {
597            var email = $('#popup_official_email').val().trim().toLowerCase();
598            if (!validateEmail(email)) {
599                isValid = false;
600                $('#popup_official_email').addClass('error');
601                $('.pop_email_error').html('Please enter a valid work email.');
602            } else {
603                $('#popup_official_email').removeClass('error');
604                $('.pop_email_error').html('');
605            }
606        }
607
608        var form = document.getElementById(formId);
609        var no_of_employee_exists = form.querySelector('#no_of_employee') !== null;
610        if (no_of_employee_exists) {
611            var no_of_employee_field = $('#no_of_employee');
612            if (no_of_employee_field.length > 0) {
613                var no_of_employee = no_of_employee_field.val();
614                if (!no_of_employee) {
615                    isValid = false;
616                    no_of_employee_field.addClass('error');
617                    $('.employee_error').html('Please select the number of employees.');
618                } else {
619                    no_of_employee_field.removeClass('error');
620                    $('.employee_error').html('');
621                }
622            }
623        }
624
625        var no_of_employee_exists = form.querySelector('#popup_no_of_employee') !== null;
626        if (no_of_employee_exists) {
627            var no_of_employee_field = $('#popup_no_of_employee');
628            if (no_of_employee_field.length > 0) {
629                var no_of_employee = no_of_employee_field.val();
630                if (!no_of_employee) {
631                    isValid = false;
632                    no_of_employee_field.addClass('error');
633                    $('.popup_employee_error').html('Please select the number of employees.');
634                } else {
635                    no_of_employee_field.removeClass('error');
636                    $('.popup_employee_error').html('');
637                }
638            }
639        }
640        // Proceed to the next step if all validations pass
641        if (isValid) {
642            $("#progressbar li.active").last().addClass("completed");
643            // Add Class Active
644            $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
645            var curr_val = $('#progBar').val();
646            var new_val = Number(curr_val) + 33;
647            $('#progBar').attr('value', new_val);
648            $("#progBar").css('width', new_val + '%');
649
650            // Show the next fieldset
651            next_fs.show();
652            // Hide the current fieldset with style
653            current_fs.animate({ opacity: 0 }, {
654                step: function (now) {
655                    // For making fieldset appear animation
656                    opacity = 1 - now;
657                    current_fs.css({
658                        'display': 'none',
659                        'position': 'relative'
660                    });
661                    next_fs.css({ 'opacity': opacity });
662                },
663                duration: 500
664            });
665        }
666    });
667
668    $(".next-step-generator").click(function (e) {
669        e.preventDefault(); // Prevent form submission
670        var formId = $(this).closest("form").attr("id");
671
672        const formData = captureAllFormData(formId);
673        var current_fs = $(this).parent();
674        var next_fs = $(this).parent().next();
675        var isValid = true;
676
677        // Check if base domains are loaded
678        if (!baseDomainsLoaded) {
679            $('.email_error').html('Please wait while the email domains are being loaded. Try again.');
680            isValid = false;
681        }
682        // Check for empty fields and mark them with an error class
683        current_fs.find("input[type='text'], input[type='email'],input, select, input[id='emp_accountNumber'],input[id='basic_salary']").each(function () {
684            var inputId = $(this).attr("id");
685            var inputValue = $(this).val().trim();
686
687            if (inputValue === '') {
688                isValid = false;
689                $(this).addClass('error');
690            } else {
691                $(this).removeClass('error');
692            }
693            if (inputId === 'emp_accountNumber') {
694                // Validate account number (minimum 6 digits, only numbers allowed)
695                if (!/^\d{6,}$/.test(inputValue)) {
696                    isValid = false;
697                    $(this).addClass('error');
698                    $('.account_number_error').html('Account number must be at least 6 digits and contain only numbers.');
699                } else {
700                    $(this).removeClass('error');
701                    $('.account_number_error').html('');
702                }
703            }
704        });
705        // Check email validation only if the current fieldset contains email input
706        if (current_fs.find("#official_email").length > 0) {
707            var email = $('#official_email').val().trim().toLowerCase();
708            if (!validateEmail(email)) {
709                isValid = false;
710                $('.email_error').html('Invalid Email Format');
711                $('#official_email').addClass('error');
712
713            } else {
714                $('#official_email').removeClass('error');
715                $('.email_error').html('');
716            }
717        }
718
719        // Initially disable the next-step button
720        $(".next-step").prop("disabled", true);
721
722        // Load the base domains before allowing any form submission
723        loadBaseDomains();
724
725        if (current_fs.find("#popup_phone_nu").length > 0) {
726            var phoneNum = $('#popup_phone_nu').val();
727            // Remove non-numeric characters
728            phoneNum = phoneNum.replace(/\D/g, '');
729            // Ensure the phone number starts with 6, 7, 8, or 9 and has a length of 2 to 10 digits
730            if (/^[6-9]\d{1,9}$/.test(phoneNum)) {
731                // Limit the phone number to 10 digits
732                phoneNum = phoneNum.slice(0, 10);
733                // Check if the phone number length is less than 10
734                if (phoneNum.length < 10) {
735                    $('#popup_phone_nu').addClass('error');
736                    isValid = false;
737                    $('.popup_phone_error').html('Phone number must be exactly 10 digits long');
738                } else {
739                    $('#popup_phone_nu').removeClass('error');
740                    $('.popup_phone_error').html('');
741                }
742            } else {
743                // If the number doesn't start with 6, 7, 8, or 9, clear the input
744                phoneNum = '';
745                isValid = false;
746                $('#popup_phone_nu').addClass('error');
747                $('.popup_phone_error').html('Insert a valid number starting with 6/7/8/9');
748            }
749        }
750        var form = document.getElementById(formId);
751        var phoneNuElement = form.querySelector('#phone_nu');
752        if (phoneNuElement !== null) {
753            var phoneNum = $('#phone_nu').val();
754            // Remove non-numeric characters
755            phoneNum = phoneNum.replace(/\D/g, '');
756            // Ensure the phone number starts with 6, 7, 8, or 9 and has a length of 10 digits
757            if (/^[6-9]\d{9}$/.test(phoneNum)) {
758                // Limit the phone number to 10 digits
759                phoneNum = phoneNum.slice(0, 10);
760                $('#phone_nu').removeClass('error');
761                $('.phone_error').html('');
762            } else {
763                $('#phone_nu').addClass('error');
764                isValid = false;
765                if (phoneNum.length < 10) {
766                    $('.phone_error').html('Phone number must be exactly 10 digits long');
767                } else {
768                    $('.phone_error').html('Insert a valid number starting with 6/7/8/9');
769                }
770            }
771        }
772
773        // Check email validation only if the current fieldset contains email input
774        if (current_fs.find("#popup_official_email").length > 0) {
775            var email = $('#popup_official_email').val().trim().toLowerCase();
776            if (!validateEmail(email)) {
777                isValid = false;
778                $('#popup_official_email').addClass('error');
779                $('.pop_email_error').html('Please enter a valid work email.');
780            } else {
781                $('#popup_official_email').removeClass('error');
782                $('.pop_email_error').html('');
783            }
784        }
785        const ctc_total_FieldExists = Object.keys(formData).some(key => {
786            const input = document.querySelector(`form input[name="${key}"]`);
787            return input.name === 'ctc_total';
788        });
789        var form = document.getElementById(formId);
790        var no_of_employee_exists = form.querySelector('#no_of_employee') !== null;
791        if (no_of_employee_exists) {
792            var no_of_employee_field = $('#no_of_employee');
793            if (no_of_employee_field.length > 0) {
794                var no_of_employee = no_of_employee_field.val();
795                if (!no_of_employee) {
796                    isValid = false;
797                    no_of_employee_field.addClass('error');
798                    $('.employee_error').html('Please select the number of employees.');
799                } else {
800                    no_of_employee_field.removeClass('error');
801                    $('.employee_error').html('');
802                }
803            }
804        }
805
806        var no_of_employee_exists = form.querySelector('#popup_no_of_employee') !== null;
807        if (no_of_employee_exists) {
808            var no_of_employee_field = $('#popup_no_of_employee');
809            if (no_of_employee_field.length > 0) {
810                var no_of_employee = no_of_employee_field.val();
811                if (!no_of_employee) {
812                    isValid = false;
813                    no_of_employee_field.addClass('error');
814                    $('.popup_employee_error').html('Please select the number of employees.');
815                } else {
816                    no_of_employee_field.removeClass('error');
817                    $('.popup_employee_error').html('');
818                }
819            }
820        }
821        var no_of_employee_exists_auto = form.querySelector('#autopopup_no_of_employee') !== null;
822        if (no_of_employee_exists_auto) {
823            var no_of_employee_field = $('#autopopup_no_of_employee');
824            if (no_of_employee_field.length > 0) {
825                var no_of_employee = no_of_employee_field.val();
826                if (!no_of_employee) {
827                    isValid = false;
828                    no_of_employee_field.addClass('error');
829                    $('.popup_employee_error').html('Please select the number of employees.');
830                } else {
831                    no_of_employee_field.removeClass('error');
832                    $('.popup_employee_error').html('');
833                }
834            }
835        }
836        // Proceed to the next step if all validations pass
837        if (isValid) {
838            $("#progressbar li.active").last().addClass("completed");
839            // Add Class Active
840            $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
841            var curr_val = $('#progBar').val();
842            var new_val = Number(curr_val) + 33;
843            $('#progBar').attr('value', new_val);
844            $("#progBar").css('width', new_val + '%');
845
846            // Show the next fieldset
847            next_fs.show();
848            // Hide the current fieldset with style
849            current_fs.animate({ opacity: 0 }, {
850                step: function (now) {
851                    // For making fieldset appear animation
852                    opacity = 1 - now;
853                    current_fs.css({
854                        'display': 'none',
855                        'position': 'relative'
856                    });
857                    next_fs.css({ 'opacity': opacity });
858                },
859                duration: 500
860            });
861        }
862    });
863
864    $(".next-step-invoicegenerator").click(function (e) {
865        e.preventDefault(); // Prevent form submission
866        var formId = $(this).closest("form").attr("id");
867        var state = $('#inputinvoicesender_boxcity').attr('data-state');
868        var states = $('#inputinvoicereciever_boxcity').attr('data-state');
869        const formData = captureAllFormData(formId);
870        var current_fs = $(this).parent();
871        var next_fs = $(this).parent().next();
872        var isValid = true;
873
874
875        // Check for empty fields and mark them with an error class
876        current_fs.find("input[required], select[required], textarea[required]").each(function () {
877
878            if (!$(this).is(':visible')) {
879                return true;
880            }
881
882            let value = $(this).val();
883            value = value ? value.toString().trim() : '';
884
885            if (value === '') {
886
887                isValid = false;
888                $(this).addClass('error');
889
890            } else {
891
892                $(this).removeClass('error');
893            }
894        });
895
896
897
898        // Load the base domains before allowing any form submission
899        if (typeof loadBaseDomains === 'function') {
900            loadBaseDomains();
901        }
902
903        function validatePhoneNumber(phoneNumberSelector, errorSelector) {
904            var phoneNum = $(phoneNumberSelector).val();
905            phoneNum = phoneNum.replace(/\D/g, '');
906
907            if (/^[6-9]\d{1,9}$/.test(phoneNum)) {
908                phoneNum = phoneNum.slice(0, 10);
909                if (phoneNum.length < 10) {
910                    $(phoneNumberSelector).addClass('error');
911                    $(errorSelector).html('Phone number must be exactly 10 digits long');
912                    return false;
913                } else {
914                    $(phoneNumberSelector).removeClass('error');
915                    $(errorSelector).html('');
916                    return true;
917                }
918            } else {
919                $(phoneNumberSelector).addClass('error');
920                $(errorSelector).html('Insert a valid number starting with 6/7/8/9');
921                return false;
922            }
923        }
924
925        // Validate phone numbers
926        if (current_fs.find('#company_contact').length > 0) {
927            isValid = validatePhoneNumber('#company_contact', '.phone_error') && isValid;
928        }
929
930        if (current_fs.find('#receiver_phone').length > 0) {
931            isValid = validatePhoneNumber('#receiver_phone', '.phone_error') && isValid;
932        }
933
934        function validateZipCode(zipCodeSelector, errorSelector) {
935            var zipCode = $(zipCodeSelector).val();
936            var zipcodeError = $(errorSelector);
937
938            if (/^\d{6}$/.test(zipCode)) {
939                zipcodeError.hide();
940                $(zipCodeSelector).removeClass('error');
941                zipcodeError.html('');
942                return true;
943            } else {
944                zipcodeError.show();
945                $(zipCodeSelector).addClass('error');
946                zipcodeError.html('Invalid ZIP Code. Must be 6 digits (0-9).');
947                return false;
948            }
949        }
950        // Validate ZIP codes
951        if (current_fs.find('#company_addressZipcode').length) {
952            isValid = validateZipCode('#company_addressZipcode', '.Zipcode-error') && isValid;
953        }
954
955        if (current_fs.find('#receiver_zipcode').length) {
956            isValid = validateZipCode('#receiver_zipcode', '.Zipcode-error') && isValid;
957        }
958
959
960
961        // Function to validate city input
962        function validateCity(inputElement) {
963
964            if (typeof availableKeywords === 'undefined') {
965                return true;
966            }
967
968            const inputCity = $(inputElement).val().trim();
969
970            const cityExists = availableKeywords.some(function (item) {
971                return item.city === inputCity;
972            });
973
974            if (!cityExists) {
975                $(inputElement).addClass('error');
976                return false;
977            }
978
979            $(inputElement).removeClass('error');
980            return true;
981        }
982
983        // Validate city fields in the current step
984        if (current_fs.find("#inputinvoicesender_boxcity").length > 0) {
985            isValid = validateCity("#inputinvoicesender_boxcity") && isValid;
986        }
987
988        if (current_fs.find("#inputinvoicereciever_boxcity").length > 0) {
989            isValid = validateCity("#inputinvoicereciever_boxcity") && isValid;
990        }
991
992        // --- GST Number Validation
993        function validateGstNumber(gstNumberSelector) {
994
995            var gstNumber = $(gstNumberSelector).val().trim().toUpperCase();
996
997            const gstRegex =
998                /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/;
999
1000            if (gstNumber === '') {
1001
1002                $(gstNumberSelector).addClass('error');
1003
1004                $('.gst-error').html('GST Number is required');
1005
1006                return false;
1007
1008            } else if (gstRegex.test(gstNumber)) {
1009
1010                $(gstNumberSelector).removeClass('error');
1011
1012                $('.gst-error').html('');
1013
1014                return true;
1015
1016            } else {
1017
1018                $(gstNumberSelector).addClass('error');
1019
1020                $('.gst-error').html(
1021                    'Invalid GSTIN format (e.g., 22AAAAA0000A1Z5)'
1022                );
1023
1024                return false;
1025            }
1026        }
1027
1028        // --- PAN Number Validation
1029        function validatePanNumber(panNumberSelector, errorSelector) {
1030
1031            var panNumber = $(panNumberSelector).val().trim().toUpperCase();
1032            var panError = $(errorSelector);
1033
1034            const panRegex = /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/;
1035
1036            if (panNumber === '') {
1037
1038                $(panNumberSelector).addClass('error');
1039
1040                if ($(errorSelector).length) {
1041                    panError.show().html('PAN Number is required');
1042                }
1043
1044                return false;
1045            }
1046
1047            if (panRegex.test(panNumber)) {
1048
1049                $(panNumberSelector).removeClass('error');
1050
1051                if ($(errorSelector).length) {
1052                    panError.hide().html('');
1053                }
1054
1055                return true;
1056            }
1057
1058            $(panNumberSelector).addClass('error');
1059
1060            if ($(errorSelector).length) {
1061                panError.show().html('Invalid PAN format (e.g. ABCDE1234F)');
1062            }
1063
1064            return false;
1065        }
1066
1067        // Company GST/PAN validation
1068        const companyType = current_fs.find('input[name="identification_type_company"]:checked').val();
1069
1070        if (
1071            companyType === 'GSTcompany' &&
1072            current_fs.find('#company_gstno').length
1073        ) {
1074
1075            isValid = validateGstNumber('#company_gstno') && isValid;
1076
1077        } else if (
1078            companyType === 'PANcompany' &&
1079            current_fs.find('#company_pan').length
1080        ) {
1081
1082            isValid = validatePanNumber('#company_pan', '#company_pan_error') && isValid;
1083
1084        }
1085
1086        // Receiver GST/PAN validation
1087        const receiverType = current_fs.find('input[name="identification_type_receiver"]:checked').val();
1088
1089        if (
1090            receiverType === 'GSTreceiver' &&
1091            current_fs.find('#receiver_gstno').length
1092        ) {
1093
1094            isValid = validateGstNumber('#receiver_gstno') && isValid;
1095
1096        } else if (
1097            receiverType === 'PANreceiver' &&
1098            current_fs.find('#receiver_pan').length
1099        ) {
1100
1101            isValid = validatePanNumber('#receiver_pan', '#receiver_pan_error') && isValid;
1102
1103        }
1104
1105        console.log('FINAL isValid =', isValid);
1106
1107        if (!isValid) {
1108            console.log('company_contact', $('#company_contact').val());
1109            console.log('company_zip', $('#company_addressZipcode').val());
1110            console.log('company_city', $('#inputinvoicesender_boxcity').val());
1111            console.log('company_gst', $('#company_gstno').val());
1112            e.preventDefault(); // Prevent moving to the next step if validation fails
1113            return false;
1114        }
1115
1116        // Proceed to the next step if all validations pass
1117        if (isValid) {
1118            next_fs.show();
1119            current_fs.animate({ opacity: 0 }, {
1120                step: function (now) {
1121                    opacity = 1 - now;
1122                    current_fs.css({
1123                        'display': 'none',
1124                        'position': 'relative'
1125                    });
1126                    next_fs.css({ 'opacity': opacity });
1127                },
1128                duration: 500
1129            });
1130        }
1131    });
1132
1133    $(".next-step-propel").click(function (e) {
1134        e.preventDefault(); // Prevent form submission
1135        var formId = $(this).closest("form").attr("id");
1136
1137        const formData = captureAllFormData(formId);
1138        var current_fs = $(this).parent();
1139        var next_fs = $(this).parent().next();
1140        var isValid = true;
1141        // Check if base domains are loaded
1142        if (!baseDomainsLoaded) {
1143            $('.email_error').html('Please wait while the email domains are being loaded. Try again.');
1144            isValid = false;
1145        }
1146        // Check for empty fields and mark them with an error class
1147        current_fs.find("input[type='text'], input[type='email']").each(function () {
1148            if ($(this).val().trim() === '') {
1149                isValid = false;
1150                $(this).addClass('error');
1151            } else {
1152                $(this).removeClass('error');
1153            }
1154        });
1155        //Check email validation only if the current fieldset contains email input
1156        if (current_fs.find("#official_email").length > 0) {
1157            var email = $('#official_email').val().trim().toLowerCase();
1158            if (!validateEmail(email)) {
1159                isValid = false;
1160                $('.email_error').html('Invalid Email Format');
1161                $('#official_email').addClass('error');
1162
1163            } else {
1164                $('#official_email').removeClass('error');
1165                $('.email_error').html('');
1166            }
1167        }
1168
1169
1170
1171        // Load the base domains before allowing any form submission
1172        loadBaseDomains();
1173
1174        var form = document.getElementById(formId);
1175        var phoneNuElement = form.querySelector('#phone_nu');
1176        if (phoneNuElement !== null) {
1177            var phoneNum = $('#phone_nu').val();
1178            // Remove non-numeric characters
1179            phoneNum = phoneNum.replace(/\D/g, '');
1180            // Ensure the phone number starts with 6, 7, 8, or 9 and has a length of 10 digits
1181            if (/^[6-9]\d{9}$/.test(phoneNum)) {
1182                // Limit the phone number to 10 digits
1183                phoneNum = phoneNum.slice(0, 10);
1184                $('#phone_nu').removeClass('error');
1185                $('.phone_error').html('');
1186            } else {
1187                $('#phone_nu').addClass('error');
1188                isValid = false;
1189                if (phoneNum.length < 10) {
1190                    $('.phone_error').html('Phone number must be exactly 10 digits long');
1191                } else {
1192                    $('.phone_error').html('Insert a valid number starting with 6/7/8/9');
1193                }
1194            }
1195        }
1196        // Proceed to the next step if all validations pass
1197        if (isValid) {
1198            $("#progressbar li.active").last().addClass("completed");
1199            // Add Class Active
1200            $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
1201            var curr_val = $('#progBar').val();
1202            var new_val = Number(curr_val) + 33;
1203            $('#progBar').attr('value', new_val);
1204            $("#progBar").css('width', new_val + '%');
1205
1206            // Show the next fieldset
1207            next_fs.show();
1208            // Hide the current fieldset with style
1209            current_fs.animate({ opacity: 0 }, {
1210                step: function (now) {
1211                    // For making fieldset appear animation
1212                    opacity = 1 - now;
1213                    current_fs.css({
1214                        'display': 'none',
1215                        'position': 'relative'
1216                    });
1217                    next_fs.css({ 'opacity': opacity });
1218                },
1219                duration: 500
1220            });
1221        }
1222    });
1223
1224    $(".next-step-propel-masterclass").click(function (e) {
1225        e.preventDefault(); // Prevent form submission
1226        var formId = $(this).closest("form").attr("id");
1227
1228        const formData = captureAllFormData(formId);
1229        var current_fs = $(this).parent();
1230        var next_fs = $(this).parent().next();
1231        var isValid = true;
1232        // Check if base domains are loaded
1233        if (!baseDomainsLoaded) {
1234            $('.email_error').html('Please wait while the email domains are being loaded. Try again.');
1235            isValid = false;
1236        }
1237        // Check for empty fields and mark them with an error class
1238        current_fs.find("input[type='text'], input[type='email']").each(function () {
1239            if ($(this).val().trim() === '') {
1240                isValid = false;
1241                $(this).addClass('error');
1242            } else {
1243                $(this).removeClass('error');
1244            }
1245        });
1246        //Check email validation only if the current fieldset contains email input
1247        if (current_fs.find("#official_email").length > 0) {
1248            var email = $('#official_email').val().trim().toLowerCase();
1249            if (!validateEmail(email)) {
1250                isValid = false;
1251                $('.email_error').html('Invalid Email Format');
1252                $('#official_email').addClass('error');
1253
1254            } else {
1255                $('#official_email').removeClass('error');
1256                $('.email_error').html('');
1257            }
1258        }
1259
1260
1261
1262        // Load the base domains before allowing any form submission
1263        loadBaseDomains();
1264
1265        var form = document.getElementById(formId);
1266        var phoneNuElement = form.querySelector('#phone_nu');
1267        if (phoneNuElement !== null) {
1268            var phoneNum = $('#phone_nu').val();
1269            // Remove non-numeric characters
1270            phoneNum = phoneNum.replace(/\D/g, '');
1271            // Ensure the phone number starts with 6, 7, 8, or 9 and has a length of 10 digits
1272            if (/^[6-9]\d{9}$/.test(phoneNum)) {
1273                // Limit the phone number to 10 digits
1274                phoneNum = phoneNum.slice(0, 10);
1275                $('#phone_nu').removeClass('error');
1276                $('.phone_error').html('');
1277            } else {
1278                $('#phone_nu').addClass('error');
1279                isValid = false;
1280                if (phoneNum.length < 10) {
1281                    $('.phone_error').html('Phone number must be exactly 10 digits long');
1282                } else {
1283                    $('.phone_error').html('Insert a valid number starting with 6/7/8/9');
1284                }
1285            }
1286        }
1287        // var form = document.getElementById(formId);
1288        // var no_of_employee_exists = form.querySelector('#no_of_employee') !== null;
1289        // if (no_of_employee_exists) {
1290        //     var no_of_employee_field = $('#no_of_employee');
1291        // if (no_of_employee_field.length > 0) {
1292        //     var no_of_employee = no_of_employee_field.val();
1293        //     if (!no_of_employee) {
1294        //         isValid = false;
1295        //         no_of_employee_field.addClass('error');
1296        //         $('.employee_error').html('Please select the number of employees.');
1297        //     } else {
1298        //         no_of_employee_field.removeClass('error');
1299        //         $('.employee_error').html('');
1300        //     }
1301        // }
1302        // }
1303
1304
1305        // Proceed to the next step if all validations pass
1306        if (isValid) {
1307            $("#progressbar li.active").last().addClass("completed");
1308            // Add Class Active
1309            $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
1310            var curr_val = $('#progBar').val();
1311            var new_val = Number(curr_val) + 33;
1312            $('#progBar').attr('value', new_val);
1313            $("#progBar").css('width', new_val + '%');
1314
1315            // Show the next fieldset
1316            next_fs.show();
1317            // Hide the current fieldset with style
1318            current_fs.animate({ opacity: 0 }, {
1319                step: function (now) {
1320                    // For making fieldset appear animation
1321                    opacity = 1 - now;
1322                    current_fs.css({
1323                        'display': 'none',
1324                        'position': 'relative'
1325                    });
1326                    next_fs.css({ 'opacity': opacity });
1327                },
1328                duration: 500
1329            });
1330        }
1331    });
1332
1333    $(".next-stepautopop").click(function (e) {
1334        e.preventDefault(); // Prevent form submission
1335        var formId = $(this).closest("form").attr("id");
1336
1337        const formData = captureAllFormData(formId);
1338        var current_fs = $(this).parent();
1339        var next_fs = $(this).parent().next();
1340        var isValid = true;
1341        // Check if base domains are loaded
1342        if (!baseDomainsLoaded) {
1343            $('.email_error').html('Please wait while the email domains are being loaded. Try again.');
1344            isValid = false;
1345        }
1346        // Check for empty fields and mark them with an error class
1347        current_fs.find("input[type='text'], input[type='email']").each(function () {
1348            if ($(this).val().trim() === '') {
1349                isValid = false;
1350                $(this).addClass('error');
1351            } else {
1352                $(this).removeClass('error');
1353            }
1354        });
1355        // Load the base domains before allowing any form submission
1356        loadBaseDomains();
1357        var form = document.getElementById(formId);
1358        var phoneNuElement = form.querySelector('#Autopopup_phone');
1359        if (phoneNuElement !== null) {
1360            var phoneNum = $('#Autopopup_phone').val();
1361            // Remove non-numeric characters
1362            phoneNum = phoneNum.replace(/\D/g, '');
1363            // Ensure the phone number starts with 6, 7, 8, or 9 and has a length of 10 digits
1364            if (/^[6-9]\d{9}$/.test(phoneNum)) {
1365                // Limit the phone number to 10 digits
1366                phoneNum = phoneNum.slice(0, 10);
1367                $('#Autopopup_phone').removeClass('error');
1368                $('.phone_error').html('');
1369            } else {
1370                $('#Autopopup_phone').addClass('error');
1371                isValid = false;
1372                if (phoneNum.length < 10) {
1373                    $('.phone_error').html('Phone number must be exactly 10 digits long');
1374                } else {
1375                    $('.phone_error').html('Insert a valid number starting with 6/7/8/9');
1376                }
1377            }
1378        }
1379        // Check email validation only if the current fieldset contains email input
1380        if (current_fs.find("#auto_popup_email").length > 0) {
1381            var email = $('#auto_popup_email').val().trim().toLowerCase();
1382            if (!validateEmail(email)) {
1383                isValid = false;
1384                $('.email_error').html('Invalid Email Format');
1385                $('#auto_popup_email').addClass('error');
1386
1387            } else {
1388                $('#auto_popup_email').removeClass('error');
1389                $('.email_error').html('');
1390            }
1391        }
1392        // var form = document.getElementById(formId);
1393        // var no_of_employee_exists = form.querySelector('#no_of_employee') !== null;
1394        // if (no_of_employee_exists) {
1395        //     var no_of_employee_field = $('#no_of_employee');
1396        // if (no_of_employee_field.length > 0) {
1397        //     var no_of_employee = no_of_employee_field.val();
1398        //     if (!no_of_employee) {
1399        //         isValid = false;
1400        //         no_of_employee_field.addClass('error');
1401        //         $('.employee_error').html('Please select the number of employees.');
1402        //     } else {
1403        //         no_of_employee_field.removeClass('error');
1404        //         $('.employee_error').html('');
1405        //     }
1406        // }
1407        // }
1408
1409
1410        // Proceed to the next step if all validations pass
1411        if (isValid) {
1412            $("#progressbar li.active").last().addClass("completed");
1413            // Add Class Active
1414            $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
1415            var curr_val = $('#progBar').val();
1416            var new_val = Number(curr_val) + 33;
1417            $('#progBar').attr('value', new_val);
1418            $("#progBar").css('width', new_val + '%');
1419
1420            // Show the next fieldset
1421            next_fs.show();
1422            // Hide the current fieldset with style
1423            current_fs.animate({ opacity: 0 }, {
1424                step: function (now) {
1425                    // For making fieldset appear animation
1426                    opacity = 1 - now;
1427                    current_fs.css({
1428                        'display': 'none',
1429                        'position': 'relative'
1430                    });
1431                    next_fs.css({ 'opacity': opacity });
1432                },
1433                duration: 500
1434            });
1435        }
1436    });
1437
1438    function validateZipCode(inputId, errorClass) {
1439        const inputField = document.getElementById(inputId);
1440        const errorMessage = inputField.parentElement.querySelector(`.${errorClass}`);
1441
1442        inputField.addEventListener('input', function () {
1443            const zipCode = inputField.value;
1444
1445            if (/^\d{6}$/.test(zipCode)) {
1446                errorMessage.style.display = 'none';
1447                inputField.setCustomValidity('');
1448                inputField.classList.remove('error');
1449                errorMessage.innerHTML = '';
1450            } else {
1451                errorMessage.style.display = 'block';
1452                inputField.setCustomValidity('Invalid ZIP Code. Must be 6 digits (0-9).');
1453                inputField.classList.add('error');
1454                isValid = false;
1455                errorMessage.innerHTML = 'Invalid ZIP Code. Must be 6 digits (0-9).';
1456            }
1457        });
1458    }
1459
1460    //first step skip employee details
1461    $(".next-step-first").click(function () {
1462        var formId = $(this).closest("form").attr("id");
1463        const formData = captureAllFormData(formId);
1464        console.log(formData);
1465        var current_fs = $(this).parent();
1466        var next_fs = $(this).parent().next();
1467        var isValid = true;
1468
1469        // Check for empty fields and mark them with an error class
1470        current_fs.find("input[type='text']:not(#company_website), input[type='file'], input[type='email']").each(function () {
1471            if ($(this).val().trim() === '') {
1472                isValid = false;
1473                $(this).addClass('error');
1474            } else {
1475                $(this).removeClass('error');
1476            }
1477        });
1478
1479        // Check email validation only if the current fieldset contains email input
1480        if (current_fs.find("#official_email").length > 0) {
1481            var email = $('#official_email').val();
1482            var atIndex = email.indexOf('@');
1483            var dotIndex = email.lastIndexOf('.');
1484            var notAcceptedDomains = ['gmail.com', 'yopmail.com', 'yahoo.com', 'aol.com', 'outlook.com', 'hotmail.com', 'icloud.com'];
1485
1486            if (
1487                email.trim() === '' ||
1488                atIndex === -1 ||
1489                dotIndex === -1 ||
1490                atIndex > dotIndex ||
1491                notAcceptedDomains.indexOf(email.slice(atIndex + 1)) !== -1 ||
1492                dotIndex === email.length - 1
1493            ) {
1494                $('#official_email').addClass('error');
1495                $('.email_error').html('Please enter a valid work email.');
1496                isValid = false;
1497            } else {
1498                $('#official_email').removeClass('error');
1499                $('.email_error').html('');
1500            }
1501        }
1502
1503        const ctc_total_FieldExists = Object.keys(formData).some(key => {
1504            const input = document.querySelector(`form input[name="${key}"]`);
1505            return input.name === 'ctc_total';
1506        });
1507
1508        // Check total CTC
1509        if (ctc_total_FieldExists) {
1510            var ctc_total = $('#ctc_total').val();
1511            if (!ctc_total) {
1512                //isValid = false;
1513                $('#ctc_total').addClass('error');
1514            } else {
1515                $('#ctc_total').removeClass('error');
1516            }
1517        }
1518
1519        if (isValid) {
1520            // Add Class Active
1521            $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
1522            var curr_val = $('#progBar').val();
1523            var new_val = Number(curr_val) + 33;
1524            $('#progBar').attr('value', new_val);
1525            $("#progBar").css('width', new_val + '%');
1526
1527            // Show the next fieldset
1528            next_fs.show();
1529            current_fs.animate({ opacity: 0 }, {
1530                step: function (now) {
1531                    opacity = 1 - now;
1532                    current_fs.css({
1533                        'display': 'none',
1534                        'position': 'relative'
1535                    });
1536                    next_fs.css({ 'opacity': opacity });
1537                },
1538                duration: 500
1539            });
1540        }
1541    });
1542
1543    $(".previous-step").click(function () {
1544        current_fs = $(this).parent();
1545        previous_fs = $(this).parent().prev();
1546
1547        // Remove class active
1548        $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
1549        $("#progressbar li.active").last().removeClass("completed");
1550        var curr_val = $('#progBar').val();
1551        var new_val = Number(curr_val) - 33;
1552        $('#progBar').attr('value', new_val);
1553        $("#progBar").css('width', new_val + '%');
1554        // Show the previous fieldset
1555        previous_fs.show();
1556
1557        current_fs.animate({ opacity: 0 }, {
1558            step: function (now) {
1559
1560                opacity = 1 - now;
1561                current_fs.css({
1562                    'display': 'none',
1563                    'position': 'relative'
1564                });
1565                previous_fs.css({ 'opacity': opacity });
1566            },
1567            duration: 500
1568        });
1569    });
1570
1571});
1572
1573
1574
1575// Download Pdf of tools letter
1576
1577jQuery(document).ready(function ($) {
1578    defaultOfferBody = $('#offerBody').html();
1579    // console.log(defaultOfferBody);
1580    async function downloadOfferPdf() {
1581        let isValid = true;
1582
1583        $('#offerForm')
1584            .find("input[required]:not(.optional-field), input[type='file'], select[required], textarea[required]")
1585            .each(function () {
1586
1587                const value = $(this).val();
1588                if (
1589                    value === null ||
1590                    value === '' ||
1591                    (Array.isArray(value) && value.length === 0)
1592                ) {
1593                    isValid = false;
1594
1595                    $(this).addClass('error');
1596
1597                    if ($(this).hasClass('js-select2')) {
1598                        $(this).next('.select2').find('.select2-selection')
1599                            .addClass('error');
1600                    }
1601
1602                } else {
1603
1604                    $(this).removeClass('error');
1605
1606                    if ($(this).hasClass('js-select2')) {
1607                        $(this).next('.select2').find('.select2-selection')
1608                            .removeClass('error');
1609                    }
1610                }
1611
1612            });
1613        // STOP PDF generation if validation fails
1614        if (!isValid) {
1615            return;
1616        }
1617        const card = document.getElementById('offerBody');
1618        const $btn = $('#submitbtn');
1619        const originalLabel = $btn.val();
1620
1621        try {
1622
1623            $btn.prop('disabled', true).val('Generating...');
1624            const canvas = await html2canvas(card, {
1625                scale: 2,
1626                useCORS: true,
1627                backgroundColor: '#ffffff',
1628                logging: false
1629            });
1630
1631            const imgData = canvas.toDataURL('image/png');
1632            const { jsPDF } = window.jspdf;
1633            const pdf = new jsPDF({
1634                orientation: 'portrait',
1635                unit: 'mm',
1636                format: 'a4'
1637            });
1638
1639            const pageWidth = pdf.internal.pageSize.getWidth();
1640            const pageHeight = pdf.internal.pageSize.getHeight();
1641
1642            const margin = 10;
1643            const imgWidth = pageWidth - (margin * 2);
1644            const imgHeight = (canvas.height * imgWidth) / canvas.width;
1645
1646            let heightLeft = imgHeight;
1647            let position = 0;
1648
1649            pdf.addImage(
1650                imgData,
1651                'PNG',
1652                margin,
1653                position + margin,
1654                imgWidth,
1655                imgHeight
1656            );
1657
1658            heightLeft -= pageHeight;
1659            while (heightLeft > 0) {
1660                position = heightLeft - imgHeight;
1661                pdf.addPage();
1662                pdf.addImage(
1663                    imgData,
1664                    'PNG',
1665                    margin,
1666                    position + margin,
1667                    imgWidth,
1668                    imgHeight
1669                );
1670
1671                heightLeft -= pageHeight;
1672            }
1673            const employeeName =
1674                ($('#employee_name').val?.() || '').trim() || 'offer-letter';
1675
1676            pdf.save(
1677                'offer-letter-' +
1678                employeeName.replace(/[^a-z0-9]/gi, '-').toLowerCase() +
1679                '.pdf'
1680            );
1681
1682            setTimeout(function () {
1683                resetOfferForm();
1684            }, 1000);
1685
1686            function resetOfferForm() {
1687                // Reset form fields
1688                $('#offerForm')[0].reset();
1689                $('#offerBody').html(defaultOfferBody);
1690                console.log(defaultOfferBody);
1691
1692            }
1693        } catch (error) {
1694            console.error(error);
1695            alert('Failed to generate PDF');
1696
1697        } finally {
1698            $btn.prop('disabled', false).val(originalLabel);
1699            $('#offerBody').html(defaultOfferBody);
1700        }
1701    }
1702
1703    $('#submitbtn').on('click', function (e) {
1704        e.preventDefault();
1705        downloadOfferPdf();
1706    });
1707
1708});
1709
1710// Pdf download for calculator
1711jQuery(document).ready(function ($) {
1712
1713    defaultOfferBody = $('#gratuityBody').html();
1714
1715    async function downloadGratuityPdf() {
1716        let isValid = true;
1717        const $form = $('#gratuityForm');
1718
1719        // Required field validation
1720        $form.find(
1721            "input[required]:not(.optional-field), input[type='file'], select[required], textarea[required]"
1722        ).each(function () {
1723
1724            const value = $(this).val();
1725
1726            if (
1727                value === null ||
1728                value === '' ||
1729                (Array.isArray(value) && value.length === 0)
1730            ) {
1731
1732                isValid = false;
1733
1734                $(this).addClass('error');
1735
1736                if ($(this).hasClass('js-select2')) {
1737                    $(this)
1738                        .next('.select2')
1739                        .find('.select2-selection')
1740                        .addClass('error');
1741                }
1742
1743            } else {
1744
1745                $(this).removeClass('error');
1746
1747                if ($(this).hasClass('js-select2')) {
1748                    $(this)
1749                        .next('.select2')
1750                        .find('.select2-selection')
1751                        .removeClass('error');
1752                }
1753            }
1754        });
1755
1756        // Gratuity years validation (only if field exists)
1757        if ($('#no_of_service_years').length) {
1758
1759            const years =
1760                parseInt($('#no_of_service_years').val()) || 0;
1761
1762            if (years < 5) {
1763
1764                $('#no_of_service_years').addClass('error');
1765
1766                $('#error_message').text(
1767                    'Minimum 5 years of service required.'
1768                );
1769
1770                isValid = false;
1771
1772            } else {
1773
1774                $('#error_message').text('');
1775            }
1776        }
1777
1778        // TDS radio validation (only if radios exist)
1779        if ($form.find('input[name="tds_for"]').length) {
1780
1781            if (!$form.find('input[name="tds_for"]:checked').length) {
1782
1783                $form.find('input[name="tds_for"]')
1784                    .closest('.radio-combo-black')
1785                    .find('.floating-radio-alert')
1786                    .text('Please select an option');
1787
1788                isValid = false;
1789
1790            } else {
1791
1792                $form.find('input[name="tds_for"]')
1793                    .closest('.radio-combo-black')
1794                    .find('.floating-radio-alert')
1795                    .text('');
1796            }
1797        }
1798
1799        if ($form.find('input[name="pan_avail"]').length) {
1800
1801            if (!$form.find('input[name="pan_avail"]:checked').length) {
1802
1803                $form.find('input[name="pan_avail"]')
1804                    .closest('.radio-combo-black')
1805                    .find('.floating-radio-alert')
1806                    .text('Please select an option');
1807
1808                isValid = false;
1809
1810            } else {
1811
1812                $form.find('input[name="pan_avail"]')
1813                    .closest('.radio-combo-black')
1814                    .find('.floating-radio-alert')
1815                    .text('');
1816            }
1817        }
1818
1819        // STOP PDF if validation fails
1820        if (!isValid) {
1821            return;
1822        }
1823
1824        const card = document.getElementById('gratuityBody');
1825
1826        const $btn = $('#gratuityBtn');
1827        const originalLabel = $btn.val();
1828
1829        try {
1830
1831            $btn.prop('disabled', true).val('Generating...');
1832
1833            const canvas = await html2canvas(card, {
1834                scale: 2,
1835                useCORS: true,
1836                backgroundColor: '#ffffff',
1837                logging: false,
1838                ignoreElements: function (element) {
1839                    return element.classList &&
1840                        element.classList.contains('calculator-sidebar-img');
1841                }
1842            });
1843
1844            const imgData = canvas.toDataURL('image/png');
1845
1846            const { jsPDF } = window.jspdf;
1847
1848            const pdf = new jsPDF({
1849                orientation: 'portrait',
1850                unit: 'mm',
1851                format: 'a4'
1852            });
1853
1854            const pageWidth = pdf.internal.pageSize.getWidth();
1855            const pageHeight = pdf.internal.pageSize.getHeight();
1856
1857            const margin = 10;
1858
1859            const maxWidth = pageWidth - (margin * 2);
1860            const maxHeight = pageHeight - (margin * 2);
1861
1862            let imgWidth = maxWidth;
1863            let imgHeight =
1864                (canvas.height * imgWidth) / canvas.width;
1865
1866            if (imgHeight > maxHeight) {
1867                imgHeight = maxHeight;
1868                imgWidth =
1869                    (canvas.width * imgHeight) / canvas.height;
1870            }
1871
1872            pdf.addImage(
1873                imgData,
1874                'PNG',
1875                margin,
1876                margin,
1877                imgWidth,
1878                imgHeight
1879            );
1880
1881            pdf.save('calculator.pdf');
1882
1883            setTimeout(function () {
1884
1885                $form[0].reset();
1886
1887                $form.find('.error').removeClass('error');
1888
1889                $('#error_message').text('');
1890                $('.floating-radio-alert').text('');
1891
1892            }, 1000);
1893
1894        } catch (error) {
1895
1896            console.error(error);
1897
1898            alert('Failed to generate PDF');
1899
1900        } finally {
1901            $btn.prop('disabled', false).val(originalLabel);
1902            $('#gratuityBody').html(defaultOfferBody);
1903        }
1904    }
1905
1906    $('#gratuityBtn').on('click', function (e) {
1907
1908        e.preventDefault();
1909        downloadGratuityPdf();
1910
1911    });
1912
1913    // Remove radio errors on selection
1914    $(document).on(
1915        'change',
1916        'input[name="tds_for"], input[name="pan_avail"]',
1917        function () {
1918
1919            $(this)
1920                .closest('.radio-combo-black')
1921                .find('.floating-radio-alert')
1922                .text('');
1923        }
1924    );
1925
1926});
1927
1928
1929// adjust bottom stciky button on mobile
1930
1931// Add active
1932document.querySelector("img.hrone-mob-nav.menu")?.addEventListener("click", function () {
1933    document.querySelector(".request_demo")?.classList.add("active");
1934});
1935
1936// Remove active
1937document.querySelector("img.hrone-mob-nav-logo-cross")?.addEventListener("click", function () {
1938    document.querySelector(".request_demo")?.classList.remove("active");
1939});
1940
1941// SCRIPT 2 — BOTTOM OF PAGE BASED
1942window.addEventListener("scroll", function () {
1943
1944    const threshold = 128.5;
1945    const btn = document.querySelector(".request_demo");
1946    if (!btn) return;
1947
1948    const scrollPos = window.scrollY || window.pageYOffset;
1949    const winHeight = window.innerHeight;
1950    const docHeight = document.documentElement.scrollHeight;
1951
1952    const nearBottom = scrollPos + winHeight >= docHeight - threshold;
1953
1954    if (nearBottom) {
1955        btn.classList.add("active");
1956    } else {
1957        btn.classList.remove("active");
1958    }
1959});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.