Vue.js Assignment– 5
Forms & Data Handling
Basic Questions
- Create a login form using v-model and submit it to log the entered values in the console.
- Use v-model.trim on a text input and show the trimmed value under the field.
- Use v-model.number on a numeric input and display its type using typeof.
- Use v-model.lazy on an input and demonstrate that updates occur only on change.
- Build a form with text, email, and checkbox fields bound via v-model to a reactive object.
- Disable the submit button until all required fields have non-empty values.
- Create a custom validator that checks email format and shows an inline error message.
- Add per-field validation states (valid/invalid) with dynamic classes on blur.
- Render a list of dynamic inputs based on an array schema and bind each with v-model.
- Create a select dropdown with v-model and render the currently selected option.
- Build a simple file input that prints the selected file name on change.
- Preview an uploaded image by creating an object URL and displaying it in an <img>.
- Add a textarea with character counter and prevent submission when over a limit.
- Reset the entire form and validation state with a single “Reset” button.
- Submit the form and show a loading spinner for two seconds before confirming success.
- Use computed to derive a “form complete” summary from multiple inputs.
- Add a radio group using v-model and show the chosen value in the UI.
- Create a password field with a toggle to show/hide characters.
- Prevent default form submission and handle the submit in a Vue method.
- Persist form data to localStorage on input and repopulate the form on page load.
Intermediate Questions
- Install and configure Vuelidate in a component and validate required fields.
- Create Vuelidate rules for email, min length, and a custom async uniqueness check.
- Display a list of validation errors per field under each input.
- Disable submit until the entire Vuelidate form is $valid.
- Implement debounced validation for a username field to avoid excessive checks.
- Build a multi-step form (wizard) and preserve form state across steps.
- Implement navigation guards in the wizard to prevent moving forward with invalid data.
- Generate form inputs dynamically from a JSON schema and bind them with v-model.
- Create a dynamic array field (add/remove rows) where each row has two inputs bound to state.
- Add a date picker component and validate that the selected date is not in the past.
- Implement file size and file type validation for an uploaded image before preview.
- Handle multiple file uploads and render a gallery of image previews.
- Build a form that posts JSON to a REST API endpoint and renders the server response.
- Add error handling for the REST request and show a dismissible alert on failure.
- Implement optimistic UI updates on submit and roll back on REST failure.
- Create a GraphQL mutation to submit form data and display the returned ID.
- Load initial form options (selects) using a GraphQL query and handle loading/error states.
- Use watch to auto-save draft form data to localStorage every 2 seconds.
- Add a custom directive that auto-focuses the first invalid input on failed submit.
- Build a reusable <FormField> component that accepts label, modelValue, rules, and emits update:modelValue.
Advanced Questions
- Implement a large, schema-driven form renderer that supports input, textarea, select, checkbox, and file fields with per-field validation.
- Build a reusable validation composable (e.g., useValidation) that handles sync and async rules and returns errors, touched, and validate().
- Implement client-side chunked file uploads to a REST endpoint with progress bars per chunk.
- Add image processing before upload (resize or compress) and upload the processed blob.
- Integrate a GraphQL file upload mutation and display server-side validation messages.
- Create a multi-step form with route-based steps, preserving state via a store (Pinia) and validating per step.
- Implement accessibility features: ARIA attributes, error descriptions, and keyboard navigation for all controls.
- Add form-level and field-level async validation that cancels outdated requests when the user types.
- Build a robust error boundary around the form that captures and logs unexpected runtime errors while preserving user input.
- Final Hands-on Project:
- Schema-driven, multi-step form with dynamic fields and conditional visibility
- Vuelidate or custom composable validation (sync + async)
- File uploads with previews, size/type checks, and resumable/chunked transfers
- REST and GraphQL submission paths with optimistic updates and rollback
- Auto-save drafts, storage persistence, and accessibility compliance
- Reusable <FormField> components and a validation composable for large-scale reuse