Overview
The Client Form component is the initial data entry form that captures essential customer information before generating vehicle inspection forms. It consists of four required fields and triggers the dynamic creation of vehicle forms.HTML Structure
The client form is rendered within the.form-section container:
- HTML
- CSS
index.html:31-56
Form Fields
nombre
- Type: Text input
- ID:
nombre - Required: Yes
- Validation: Automatically capitalizes first character (script.js:509-515)
- Purpose: Customer’s first name
apellidos
- Type: Text input
- ID:
apellidos - Required: Yes
- Validation: Automatically capitalizes first character (script.js:509-515)
- Purpose: Customer’s last name(s)
razonSocial
- Type: Text input
- ID:
razonSocial - Required: Yes
- Validation: Automatically capitalizes first character (script.js:509-515)
- Purpose: Business name or individual designation
nAutos
- Type: Text input
- ID:
nAutos - Required: Yes
- Validation:
- Only numeric input allowed (script.js:502-506)
- Min value: 1
- Max value: 50 (script.js:22-25, 489-499)
- Purpose: Number of vehicles to inspect
Related Functions
enviar()
Main function that validates the client form and triggers vehicle form generation.script.js:8-39
- Validates all required fields are filled
- Validates vehicle count is between 1-50
- Clears any existing vehicle forms
- Generates new vehicle forms based on count
- Adds calculate button
- Shows loading animation
obtenerDatosCliente()
Retrieves client data from the form fields.script.js:154-161
Object
nombre(string): Customer first nameapellidos(string): Customer last name(s)razonSocial(string): Business namenAutos(number): Number of vehicles
inicializarEventos()
Sets up real-time validation and input enhancement for form fields.script.js:487-516
- Restricts vehicle count input to numeric values only
- Enforces maximum of 50 vehicles
- Auto-capitalizes first letter of text fields
CSS Classes
.form-section
Main container for the client form.styles.css:64-71
.bloque1
Grid container for input groups within the client form.styles.css:97-106
.input-group
Vertical flex container for label and input pairs.styles.css:109-113
.btn-primary
Primary button styling for the submit button.styles.css:146-164
Usage Example
Validation Rules
| Field | Rule | Error Message |
|---|---|---|
| nombre | Required, non-empty | ”Por favor, complete todos los campos obligatorios.” |
| apellidos | Required, non-empty | ”Por favor, complete todos los campos obligatorios.” |
| razonSocial | Required, non-empty | ”Por favor, complete todos los campos obligatorios.” |
| nAutos | Required, numeric, 1-50 | ”Por favor, ingrese un número válido de vehículos (1-50).” |
Responsive Behavior
The form adapts to different screen sizes:- Desktop (>768px): Grid layout with auto-fitting columns
- Tablet (768px): Single column layout (styles.css:439-442)
- Mobile (<480px): Compressed padding and font sizes (styles.css:469-471)
Accessibility Features
- All inputs have associated
<label>elements withforattributes - Required fields marked with
requiredattribute - Placeholder text provides input hints
- Focus states with visible outlines (styles.css:133-138)
- Error messages displayed visually via
mostrarError()function