Q:

Web2py Java Script Pop Up Form

I have a contact form in Web2py that sends an email to a user from their profile.
It works fine on the regular page but the Captcha screwed up my design so i wanted to put it in a pop up window.
I used the Java pop up here.
http://blog.theonlytutorials.com/a-very-simple-jquery-popup-ready-to-use-code/
Here is my View:
<a href="#" id="pop"><img src="/init/static/images/envelope-small.gif" border="0" Title="Send A Message"></a></h1>
         <div id="overlay_form" style="display:none">
             <center> <h3>Send {{=user.company_name}} A Message</h3> </center>
     {{=contact.custom.begin}}
         Your Email:<br>
         {{=contact.custom.widget.your_email}}
         <br>
         Your Message:<br>
        {{=contact.custom.widget.question}}

        {{=captcha}}
         <center> 
         {{=contact.custom.submit}}
         </center>
         <a href="#" id="close" >Close</a>
         {{=contact.custom.end}}
    </div>

When i click on the pop up it brings up the form and will send an email if all the fields are correct. However if the form has errors it will close the pop up and notify in the flash box.
I would like the pop up to stay open if the form has errors so they can be corrected. I figure the form validation causes a reload so the pop up closes but i figure the must be some way to keep it open.
Am i way off base trying to do it this way? Seems with Web2py there is always a really simple solution but i can not seem to find  it.
suggestions?

A:

You can't keep the pop-up open because the entire page is re-loading with the form submission. However, when a form is returned with errors, you could add some Javascript code to the page that automatically opens the pop-up as soon as the page loads.
Another option is to submit the form via Ajax, which avoids the full-page re-load.

