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

Responsive contact form with HTML, CSS, and JS

fetch
Adriano•330
@adriano-wb
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?

I am proud of having done this form so accurately, of course it is not one of the best, but I can see the difference in my ability between today and two years ago. I feel that I need to learn new technologies to benefit from the time spent developing projects and the quality of my code for other developers.

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

The only challenges were sending the form, as I am a perfectionist, I thought about sending it for real, however, I had to improvise using fetch to display the success message.

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

I would like to know which technologies could help me even more in this type of project. What are the current trends?

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Jean Gabriel Rodrigues•330
    @theJRodrigues
    Posted 5 months ago

    Um bom código man, parabéns, só teria algumas coisas que eu mudaria no html e css.

    HTML

    1- Inputs dentro das labels: Para um bom link entre a label e o input, podemos utilizar o input já dentro da label, isso faz com que ao clicar em cima do texto da label, ele selecione o input, vou dar um exemplo no seu código.

    Seu código:

    <div class="nomes-flex__item">
       <label for="sobreNome">Last Name <span class="prefixo">*</span></label>
       <input type="text" id="sobreNome" name="ultimoNome" maxlength="15" required>
       <span class="atencao-sobreNome-vazio">This field is required</span>
    </div>
    

    Melhor:

    <label>
     <h2>Titulo da label</h2> 
     <input type="text" name="ultimoNome" maxlength="15" required>
     <span class="">This field is required</span>
    </label>
    

    Quando você utiliza o input dentro da label, não é necessário utilizar o atributo "for" nem o "id" no input para que o link funcione.

    2- Fieldset: O fieldset serve para agrupar elementos realcionados em um formulário. Como no caso dos inputs de first name e last name, onde você pode utilizar um fieldset para eles dois e depois um fieldset para o input de e-mail, conforme o código a seguir:

    <fieldset>
     <label >
    	<h2>First Name *</h2>
    	<input type="text" name="primeiroNome" maxlength="15" required>
    	<span class="atencao-nome-vazio">This field is required</span>
     </label>
    
     <label >
    	<h2>Last Name *</h2>
    	<input type="text" name="ultimoNome" maxlength="15" required>
        <span class="atencao-sobreNome-vazio">This field is required</span>
     </label>
    </fieldset>
    

    Teria mais algumas coisas para falar, mas acredito que esses são os principais pontos da parte de HTML.

    CSS

    Para o css, seria bom em pensar uma maneira de diminuir a complexidade da escrita do css, fazer em ordem, conforme no html.

    Um bom ponto também seria dar nomes as classes e inglês e ao invés de estilizar os inputs utilizando input[type=...] criar uma classe, e incluir dentro do HTML, pois ao bater o olho no HTML da pra ver que ele possuí um estilo, não sendo necessário procurar em outro arquivo.

    Um exemplo bom seria esse:

    Seu código:

    input[name=primeiroNome],
    input[name=ultimoNome],
    input[name=email] {
    ...
    }
    

    Melhor:

    .inputText{
    ...}
    

    E incluir essa classe nos inputs necessário

    Vi que você utilizou e-mails para os radio button e checkbox por conta das cores. Nesse caso não é necessário, basta apenas estilizar com accent-color: 'cor'

    Não consegui olhar seu script, portanto não conseguirei opinar. Enfim, sempre desenvolva pensando se uma pessoa leiga iria entender o seu código, não precisa ser o mais rápido, pois as vezes você pode ser rápido para escrever, mas irá perder todo o tempo que ganhou, tentando dar manutenção no código.

    Espero ter ajudado! Tmjj!

    Marked as helpful
  • P
    Shaimaa01•200
    @Shaimaa01
    Posted 5 months ago

    use formik with yep https://formik.org/docs/tutorial#schema-validation-with-yup

    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
Frontend Mentor logo

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, SASS, 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

Oops! 😬

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

Log in with GitHub