# Ticket Frontend Validation Plan (Backend-Aligned) Date: 2026-03-31 Scope: - `app/Views/ticket_form_gmc.php` - `app/Views/ticket_form_gpa.php` - `app/Views/ticket_form_motor.php` - `app/Views/ticket_note.php` - `app/Views/ticket_reply.php` - `app/Views/ticket_feedback_form.php` Reference backend: - `app/Controllers/TicketController.php` - `createTicket()` - `updateTicket()` - `crudNote($action = 2)` - `saveReply()` - `viewClaimFeedbackForm()` (current behavior, no server-side field validation) --- ## 1) Objective Implement consistent JavaScript validation in the six target view files so frontend checks match the current backend rules and reduce avoidable 400 responses. Validation must remain non-breaking with current dynamic field visibility and existing submit/AJAX flows. Enhance current submit-time validation to real-time validation using `oninput` / `onchange` event-driven checks, so users get immediate feedback before submit. --- ## 2) Backend Rule Mapping Summary ## `ticket_form_gmc.php` (ticket type `1` / `72`) - Required: `emp_code`, `emp_name`, `insured_name`, `relationship`, `emp_mobile`, `emp_mail`, `client_policy_id`, `acm_id`, `claim_status_id`, `priority`, `mode_of_intimation`, `claim_type`, `hospital_name`, `doa`, `dod`. - Optional with format checks: - `policy_no`: regex + length constraints. - `tpa_no`: regex. - `emp_personal_mail`: email regex. - `hospital_address`, `hospital_state`, `hospital_city`, `hospital_pin_code`, `hospital_phone_no`. - `claim_amount`, `approved_amount`, `si_amt`: numeric. - date-format optional fields: `registration_date`, `denial_date`, `approved_date`, `settled_date`, `pay_initiate_date` (`dd/mm/yyyy`). - `pod_no`, `claim_number`, `utr_details`. - Conditional front-end behavior already present and retained: - Claim-status based dynamic required fields (`extra_fields_array_for_validate`). - `pod_no` required when `mode_of_intimation == 2`. - TPA-specific required fields via `handleTPARequired(tpaId)`. ## `ticket_form_gpa.php` (non-`1/72/8` path) - Required: `emp_code`, `emp_name`, `emp_mobile`, `emp_mail`, `client_policy_id`, `acm_id`, `claim_status_id`, `claim_type`, `dob`, `date_of_intimat`, `si_amt`. - Optional with format checks: - `emp_personal_mail` (email regex), - `approved_amount` numeric, - `approved_date`, `settled_date`, `pay_initiate_date` (`dd/mm/yyyy`), - `utr_details` (`alpha_numeric_punct` compatible), - remarks/letters are permit-empty. ## `ticket_form_motor.php` (ticket type `8`) - Required: `client_name` (not default value), `vehicle_id`, `client_policy_id`, `insurer_id`, `emp_mobile` (10 digits numeric), `emp_mail` (email format), `ticket_type_id`, `claim_status_id`, `client_id`. - Current frontend has partial select validation only; needs backend parity for mobile/email and hidden key integrity. ## `ticket_note.php` - Required: `note`. - Length: min `3`, max `1000`. ## `ticket_reply.php` - Required: `emp_mail` valid email. - Required: `mail_subject` min length `5`. - Content editor (`mail_content`) currently not backend-required. ## `ticket_feedback_form.php` - Current backend behavior: accepts/stores posted payload as JSON without field validation. - Frontend should keep current required radio-group checks (Parsley based), aligned to present backend behavior choice from user. --- ## 3) Per-File Frontend Implementation Plan ## A. `ticket_form_gmc.php` - [x] Added centralized validators in existing `