From 8b1502f6be82ec4d928d53eafc7acefc3e27c582 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 16 May 2025 08:55:22 +0000 Subject: [PATCH] Assigned Issues fixes --- app/Views/addemppaydate.php | 52 +++++++++++++++++++------------------ app/Views/editOldemppay.php | 18 +++++++++++-- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/Views/addemppaydate.php b/app/Views/addemppaydate.php index dd826e54..7f8a8046 100755 --- a/app/Views/addemppaydate.php +++ b/app/Views/addemppaydate.php @@ -73,8 +73,8 @@
-
@@ -246,33 +246,35 @@ }); - function duecalculation() { - var totaldue = 0; - var loan = document.getElementById('Loan_Amount').value; - var no_of_due = document.getElementById('no_of_due').value; - $('#remaining_due').val(no_of_due); - - if (loan != 0) { - if (no_of_due == 0) { - alert("Enter No Of Due"); - $('#no_of_due').focus(); - } else { - - - totalDueAmt = loan / no_of_due; - - document.getElementById('monthly_due').value = Math.ceil(totalDueAmt); - - + function duecalculation() { + var loan = parseFloat(document.getElementById('Loan_Amount').value); + var no_of_due_raw = document.getElementById('no_of_due').value.trim(); + // Validate: not empty and matches 1–99 (no 0s or more than 2 digits) + if (no_of_due_raw !== '') { + if (!/^(?:[1-9]|[1-9][0-9])$/.test(no_of_due_raw)) { + alert("Please enter a valid Number of Dues (Minimum 1 digit,Maximum 2 Digit)."); + document.getElementById('no_of_due').focus(); + document.getElementById('no_of_due').value = ''; + $('#monthly_due').val(''); + $('#remaining_due').val(''); + return; + } } + + var no_of_due = parseInt(no_of_due_raw, 10); + $('#remaining_due').val(no_of_due); + + if (!isNaN(loan) && loan > 0) { + var totalDueAmt = loan / no_of_due; + document.getElementById('monthly_due').value = Math.ceil(totalDueAmt); + } else { + $('#monthly_due').val(''); + } + + dateCalulation(); // Update your dates } - - dateCalulation(); - - - } function dateCalulation() { //alert('j'); diff --git a/app/Views/editOldemppay.php b/app/Views/editOldemppay.php index 8ae558df..9ebd921c 100755 --- a/app/Views/editOldemppay.php +++ b/app/Views/editOldemppay.php @@ -195,7 +195,7 @@ if (!empty($emppay)) {
- +
@@ -440,7 +440,21 @@ if (!empty($emppay)) { function duecalculation() { var totaldue = 0; var loan = document.getElementById('Loan_Amount').value; - var no_of_due = document.getElementById('no_of_due').value; + var no_of_due_raw = document.getElementById('no_of_due').value.trim(); + + if (no_of_due_raw !== '') { + if (!/^(?:[1-9]|[1-9][0-9])$/.test(no_of_due_raw)) { + alert("Please enter a valid Number of Dues (Minimum 1 digit,Maximum 2 Digit)."); + document.getElementById('no_of_due').focus(); + document.getElementById('no_of_due').value = ''; + $('#monthly_due').val(''); + $('#remaining_due').val(''); + $('#balance_due_amount').val(''); + return; + } + } + + var no_of_due = parseInt(no_of_due_raw, 10); if (loan != 0) { if (no_of_due == 0) {