Jump to content

how I can clean input fileds of contact form after filling and clicking submit button with set timeout in jquery?


johannes999

Recommended Posts

I have build contact-form with p

<div class="container-form">

<form id="contact" autocomplete="off"  method="post" action="">

<h3>Quick Contact</h3>

<h4>Contact us today, and get reply with in 24 hours!</h4>

<fieldset>

<input placeholder="Your name" type="text" name="name_sender" id="name_sender" value="<?php echo $name_sender;?>">

<span class="error">* <?php echo $nameErr; ?></span>

</fieldset>

<fieldset>

<input placeholder="Your Email Address" type="text" name="email_sender" id="email_sender" value="<?php echo $email_sender;?>">

<span class="error">* <?php echo $emailErr; ?></span>

</fieldset>

<fieldset>

<input placeholder="Your phone number" type="text" name="phone" id="phone" value="<?php echo $phone;?>">

<span class="error">* <?php echo $phoneErr; ?></span>

</fieldset>

<fieldset>

<textarea placeholder="Type your message here.." type="text" name="content"><?php echo $content;?></textarea>

<span class="error">* <?php echo $contentErr; ?></span>

</fieldset>

<fieldset>

<button name="submit" type="submit" id="submit" class="submit">Submit</button></fieldset>

</form></div>

hp  evrything is OK.

there is only 1 problem .

when I submit and send email the email been send but the informations remains in  the field . I want to clean after submitting all the fields after 10 seconds with Jquery.

this is my  HTML code  :





this is my  JS code:

 

<script>

$(document).ready(function () {

$("#submit").click(function(){

  setTimeout(function () {

      $('#submit').hide();

  }, 10000);

}

});

</script>



when you go to my website :  https://webdesignleren.com/contact/

you can see when you input your records in the field after submitting all the information stays there and it is not cleand .

I know the reason because I put echo class in contact form for if some one forgets something then he has not to fill again all records .

I want to know how with set timeout I can clean all this fields with Jquery?

thanks

Link to comment
Share on other sites

thanks ,

I didn't get any message on my email box tath my thread is been answered .  I have just log in today to ask question  and I saw your reply.

thank you very much I have resolved the problem with redirecting to thank you page .

I created first thank you page then I used this code:

echo '<script type="text/javascript">window.location.href="https://webdesignleren.com/dank-u-wel/"</script>';

then I updated the form action class with my thanks page url:

<div class="container-form">
<form id="contact" action= "https://webdesignleren.com/dank-u-wel/"  autocomplete="off"  method="post"> 

thanks 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...