title: Netlify Form Submission
body: <p>I have this form here :</p>
  <pre><code>&lt;form
            name=&quot;contact&quot;
            method=&quot;POST&quot;
            data-netlify=&quot;true&quot;
            id=&quot;main-form&quot;
            class=&quot;d--flex flex--column contact__form&quot;
          &gt;
            &lt;input
              type=&quot;text&quot;
              name=&quot;name&quot;
              id=&quot;name&quot;
              placeholder=&quot;Name&quot;
              class=&quot;bg--secondary&quot;
            /&gt;
            &lt;div id=&quot;nameError&quot; class=&quot;error--msg&quot;&gt;Please enter your name.&lt;/div&gt;
            &lt;input
              type=&quot;email&quot;
              name=&quot;email&quot;
              id=&quot;email&quot;
              placeholder=&quot;Enter email&quot;
              class=&quot;bg--secondary&quot;
            /&gt;
            &lt;div id=&quot;emailError&quot; class=&quot;error--msg&quot;&gt;
              Please enter a valid email adress.
            &lt;/div&gt;
            &lt;textarea
              name=&quot;message&quot;
              id=&quot;message&quot;
              cols=&quot;30&quot;
              rows=&quot;10&quot;
              placeholder=&quot;Enter your message&quot;
              class=&quot;bg--secondary&quot;
            &gt;&lt;/textarea&gt;
            &lt;div id=&quot;messageError&quot; class=&quot;error--msg&quot;&gt;
              Please tell me why do you want to contact me.
            &lt;/div&gt;
            &lt;button type=&quot;submit&quot; class=&quot;btn btn--secondary&quot;&gt;Submit&lt;/button&gt;
          &lt;/form&gt;
  </code></pre>
  <p>And I have some validation with javascript here :</p>
  <pre><code>function formError(e) {
    e.preventDefault();
  
    const nameValue = nameInput.value;
    const emailValue = emailInput.value;
    const messageValue = messageInput.value;
  
    if (nameValue.length &lt;= 0) {
      nameInput.classList.add(&quot;error--border&quot;);
      nameError.classList.add(&quot;error&quot;);
  
      setTimeout(() =&gt; {
        nameInput.classList.remove(&quot;error--border&quot;);
        nameError.classList.remove(&quot;error&quot;);
      }, 5000);
    }
    if (!emailValidation(emailValue)) {
      emailInput.classList.add(&quot;error--border&quot;);
      emailError.classList.add(&quot;error&quot;);
      setTimeout(() =&gt; {
        emailInput.classList.remove(&quot;error--border&quot;);
        emailError.classList.remove(&quot;error&quot;);
      }, 5000);
    }
  
    if (messageValue.length &lt;= 0) {
      messageInput.classList.add(&quot;error--border&quot;);
      messageError.classList.add(&quot;error&quot;);
  
      setTimeout(() =&gt; {
        messageInput.classList.remove(&quot;error--border&quot;);
        messageError.classList.remove(&quot;error&quot;);
      }, 5000);
    }
  }
  </code></pre>
  <p>The problem is since I use the preventDefault() this form isn't submitting anymore and if I take it out and I try to submit the form with errors for example I leave the name blank the JS still works and puts the error but my page reloads and not sure how to fix this problem, this is my first time I tried to do a form submission and if someone would give me any advice I will appreciate it alot!</p>