Welcome to the React Form with Validation project! This project demonstrates how to create a robust form in React with validation for required fields, display error messages, and disable form submission until all fields are correctly filled. Upon successful submission, the details are displayed on a new route. This project does not rely on any third-party libraries for validation, making it a perfect learning resource for understanding basic form handling in React.
- Field Validation: Ensures that all required fields are filled out correctly.
- Error Messages: Provides user-friendly error messages for incomplete or incorrect fields.
- Show/Hide Password: Toggle visibility of the password field.
- Dynamic Dropdowns: Country and city dropdowns to select geographical locations.
- Submission Control: Disables the submit button until all fields are correctly filled.
- Data Display: Shows all entered details on a new route after successful submission.
- First Name
- Last Name
- Username
- Password
- Phone Number (with country code)
- Country (dropdown)
- City (dropdown)
- PAN Number
- Aadhar Number
- Node.js installed on your machine
- Clone the repository
git clone https://github.com/teerthesh706/React-Form-Validation.git
- Navigate to the project directory
cd react-form-validation
- Install the dependencies
npm install
- Start the development server
npm start
- Open your browser and navigate to
http://localhost:3000
You should now see the form ready to be filled out. π
- Required Fields: Each field has a validation check to ensure it is not empty.
- Email Validation: Checks if the email entered is in a valid format.
- Phone Number Validation: Ensures the phone number is entered along with the country code.
- Dropdown Selection: Ensures a country and city are selected from the dropdowns.
- PAN and Aadhar Number Validation: Basic checks for proper formats.
- The submit button is disabled until all fields are valid.
- On successful submission, the data is displayed on a new route
/success
.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
If you have any questions or suggestions, feel free to reach out!