diff --git a/resources/views/form/rapport-glenmarkcv/1779081113-c6488e84-aeba-4ab8-b468-eb470ee6cc35.blade.php b/resources/views/form/rapport-glenmarkcv/1779081113-c6488e84-aeba-4ab8-b468-eb470ee6cc35.blade.php index 0aeca44b..e4db376e 100644 --- a/resources/views/form/rapport-glenmarkcv/1779081113-c6488e84-aeba-4ab8-b468-eb470ee6cc35.blade.php +++ b/resources/views/form/rapport-glenmarkcv/1779081113-c6488e84-aeba-4ab8-b468-eb470ee6cc35.blade.php @@ -73,13 +73,25 @@ value="{{isset($question->value)?$question->value:''}}"> @break @case('number') - required == 'yes'?'required':'' }} - value="{{isset($question->value)?$question->value:0}}" - {{ $question->code == 'total_lobg_rx' ? 'readonly' : '' }}> + + required == 'yes'?'required':'' }} + + value="{{isset($question->value)?$question->value:0}}" + + {{ $question->code == 'total-lobg-rx' ? 'readonly' : '' }}> + @break @case('textarea') @@ -300,16 +312,42 @@ function calculateTotalLOBGRx() { - let loBgRx = parseFloat($('#field-lo_bg_05_mg_rx').val()) || 0; + let loBgRx = parseInt( + $('#field-lo-bg-05-mg-rx').val() + ) || 0; - $('#field-total_lobg_rx').val(loBgRx); + $('#field-total-lobg-rx').val(loBgRx); } - // Trigger on typing/change - $('#field-lo_bg_05_mg_rx').on('keyup change', function () { - calculateTotalLOBGRx(); - }); + $(document).on( + 'input keyup change', + '#field-lo-bg-05-mg-rx', + function () { + this.value = this.value.replace(/[^0-9]/g, ''); + + calculateTotalLOBGRx(); + } + ); + $('#report-form').on('submit', function(event){ + + let loBgRx = parseInt( + $('#field-lo-bg-05-mg-rx').val() + ) || 0; + + let totalRx = parseInt( + $('#field-total-lobg-rx').val() + ) || 0; + + if (loBgRx !== totalRx) { + + event.preventDefault(); + + alert('Total LOBG Rx is mismatched.'); + + return false; + } + }); var today = new Date(); var dd = String(today.getDate()).padStart(2, '0'); var mm = String(today.getMonth() + 1).padStart(2, '0');