# Refresh form without refreshing the page

**URL:** <https://community.hubspot.com/t/refresh-form-without-refreshing-the-page/19211>\
**Category:** CMS Development\
**Tags:** javascript, forms\
**Created:** [March 4, 2020, 3:15pm UTC](https://community.hubspot.com/t/refresh-form-without-refreshing-the-page/19211 "2020-03-04T15:15:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![RLeo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rleo/32/9140_2.png) [@RLeo](https://community.hubspot.com/u/RLeo)\
**Post date:** [February 22, 2022, 3:38pm UTC](https://community.hubspot.com/t/refresh-form-without-refreshing-the-page/19211/4 "2022-02-22T15:38:45Z")

</div>

Hi YChuskit,

I know its a bit late, but one way I found is to create the form again after submitting the form. Just make sure to display a thank you message on the form settings (no redirect).

Tested it and works:

```lia-code-sample
$(document).ready(function(){

 window.addEventListener('message', event => {
 if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') {
 hbspt.forms.create({
 region: "na1",
 portalId: "{{ADD YOUR PORTAL ID HERE}}",
 formId: event.data.id,
 target: ".modal-body" // Add the element class where you need to create the form again
 });
 }
 });

 });

```

Regards,

---

_[View the full topic](https://community.hubspot.com/t/refresh-form-without-refreshing-the-page/19211)._
