Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 10 months ago

Authentication Validation Contact Form

react, tailwind-css
Muhammad Saim Khan•190
@Muhammad-Saim-Khan
A solution to the Contact form challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

"Thank you for reaching out to us! Your message has been successfully submitted, and our team will get back to you shortly. We appreciate your patience and look forward to assisting you. If you have any urgent queries, feel free to contact us directly through our support email or phone number. Have a great day!"

What challenges did you encounter, and how did you overcome them?

Challenges Encountered: During the process of building the project, one of the major challenges I faced was ensuring the form validation was both user-friendly and functional. Initially, getting the form fields to properly validate inputs, especially the email field with regex, was a bit tricky. Additionally, making the form fully responsive across all screen sizes required multiple iterations to get the layout just right.

How I Overcame Them: To resolve the validation issues, I spent time debugging and refining the regex for email, while also improving the error messages to make them clearer for users. For responsiveness, I used Tailwind CSS and ensured to test the form on different devices and viewports, tweaking the design until it looked perfect on all screens.

What specific areas of your project would you like help with?

There are a few specific areas where I would appreciate some help:

Form Validation: While the form is working fine, I want to make sure the validation is as robust as possible. I'm currently using regex for email validation, but I want to know if there are better approaches or best practices for handling form validation more efficiently, especially with larger forms.

Responsive Design: Although the design is responsive, I'm looking for feedback on optimizing it further for mobile devices. Specifically, I want to ensure that the layout scales smoothly across all screen sizes without any issues in spacing or alignment.

Code Optimization: I feel that some parts of my code could be refactored to make it cleaner and more maintainable. I'd appreciate advice on how to better structure my state management or simplify some of the event handlers.

Error Handling: Currently, I'm handling form errors with basic useState. Are there better ways to manage form errors, perhaps using React Hook Form, Yup, or Zod for validation?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Motunrayo Adeneye•880
    @motuncoded
    Posted 10 months ago

    Congratulations to you on the completion of the project.

    Few suggestions for a better HTML structure:

    1. <p className="text-[14px] text-[#383a3b] mb-1 font-normal"> First Name <span className="text-[#0d6eff]">*</span> </p> can be changed to <label htmlFor="firstname" className="text-[14px] text-[#383a3b] mb-1 font-normal"> First Name <span className="text-[#0d6eff]">*</span> </label> and for every input field.
    2. The p tag for the error can be changed to this <p id="error-message" aria-live="assertive">{error.message}</p> to allow screen readers to understand that it is validation errors.

    hope this is useful

    Marked as helpful

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub