The forms that Form Builder creates are use client side js to perform the spry validations but other than this it makes use of server side validations. In order for the form to work correctly you will need to submit the form. There is usually a redirect that will occur after the server side processing to send you to a new page.
I'm not familiar with the tools and js version that you are working with to achieve this result. If the layer you are working with is a stand alone page you could redirect it to another page that just has some js on it that does a window.close when the page loads.