Exponecial
Exponecial

Reputation: 318

How to clear field when submitting form

I'm using <iframe name="votar" style="display:none;"></iframe> To submit the form without without redirecting the tab, but the "Type something..." field is not is not displayed again when submitted.
The submit button is <button class="login100-form-btn"> submit </button>
And I already tried with <button class="login100-form-btn" type="reset"> submit </button>
What clears the field but does not submit the form
I also got the idea to put a link when pressed to send.
The page reloads the field comes back empty but the form is not submitted, doing so
<a href="http://www.pseudo.link"><button class="login100-form-btn">submit</button></a>
Also tried using <meta http-equiv="refresh" content="5; url=http://www.pseudo.link">
what made the page at a given second refresh all the time

<div class="limiter">
  <div class="container-login100" style="background-image: url('images/bg-01.jpg');">
    <div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-54">
      <iframe name="votar" style="display:none;"></iframe>
      <form action="https://docs.google.com/forms/d/e/.../formResponse" target="votar">
        <span class="login100-form-title p-b-49">Make a comment.</span>
        <div class="wrap-input100 validate-input m-b-23" data-validate="Username is reauired">
          <input class="input100" type="text" name="entry.???" placeholder="Type something...">
        </div>
        <div class="container-login100-form-btn">
          <div class="wrap-login100-form-btn">
            <div class="login100-form-bgbtn"></div>
            <button class="login100-form-btn">submit</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>

Upvotes: 0

Views: 89

Answers (2)

francisco
francisco

Reputation: 2119

Just added to the <form> a onsubmit='this.submit();this.reset();return false;'

<div class="limiter">
  <div class="container-login100" style="background-image: url('images/bg-01.jpg');">
    <div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-54">
      <iframe name="votar" style="display:none;"></iframe>
      <form action="https://docs.google.com/forms/d/e/.../formResponse" target="votar" onsubmit='this.submit();this.reset();return false;'>
        <span class="login100-form-title p-b-49">Make a comment.</span>
        <div class="wrap-input100 validate-input m-b-23" data-validate="Username is reauired">
          <input class="input100" type="text" name="entry.???" placeholder="Type something...">
        </div>
        <div class="container-login100-form-btn">
          <div class="wrap-login100-form-btn">
            <div class="login100-form-bgbtn"></div>
            <button class="login100-form-btn">submit</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>

Upvotes: 1

Shilpe Saxena
Shilpe Saxena

Reputation: 296

You need to add a script.js file or javascript code into your file where you have to write code to submit the form. And there write submit function with .reset() property and don't prevent the default form action in that code

Upvotes: 0

Related Questions