Overview
At Paytm, ensuring data accuracy and a smooth user experience is paramount. For our users to securely manage their accounts and access various services, we often require them to update their profile information. This problem simulates a simplified version of a profile update form, focusing on robust client-side validation to provide immediate feedback to users and prevent invalid data submission.
What you need to do / Task
Your task is to build a React application that renders a "Paytm Profile Update" form. This form should capture user details and implement client-side validation for each field.
- Form Fields:
- Full Name: Text input.
- Mobile Number: Text input (numeric keyboard preferred).
- Email Address: Text input (email type preferred).
- PAN Number (Optional): Text input.
- Date of Birth: Date input.
- Validation Rules:
- Full Name:
- Required.
- Minimum 3 characters, maximum 50 characters.
- Only alphabets (A-Z, a-z) and spaces are allowed.
- Mobile Number:
- Required.
- Exactly 10 digits.
- Must start with 6, 7, 8, or 9.
- Email Address:
- Required.
- Must be a valid email format (e.g.,
user@domain.com).
- PAN Number (Optional):
- If provided, must be exactly 10 characters long.
- Format:
AAAAA####A (5 uppercase alphabets, 4 digits, 1 uppercase alphabet).
- Date of Birth:
- Required.
- Must be a valid date.
- User must be at least 18 years old (calculated from the current date).
- Form Submission:
- On successful submission (all fields valid), display a success message and log the form data to the console.
- If validation fails, prevent submission and display appropriate error messages for each invalid field.
UI/UX expectations
- The form should be clearly laid out with labels for each input field.
- Error messages should appear directly below the respective input fields when validation fails.
- The "Update Profile" button should be disabled until all required fields are filled and valid.
- Basic styling is expected for readability and a clean appearance.
Acceptance criteria
- The form renders correctly with all specified input fields and an "Update Profile" button.
- Each input field correctly applies its specified validation rules on blur or change events.
- Error messages are displayed clearly and contextually for invalid inputs.
- The "Update Profile" button is disabled initially and when any required field is invalid or has validation errors.
- The "Update Profile" button becomes enabled only when all required fields are filled and valid.
- Upon successful submission, a success message is displayed, and form data is logged to the console.
- Upon unsuccessful submission, specific error messages are shown, and submission is prevented.