JQuery: re-opening Modal popup
<p>I have a JQuery modal popup form on a classic ASP page.  It's set up for the user to click a link to open the form.  They enter their email address, and submit the form.  What I'd like to do is check if the email is in my database and if it's not, re-load the modal popup form with an error message.</p>

<p>The form is working fine, but I'm not sure how to have the form pop up again if the email wasn't found without setting up another popup for that.  I'm just starting JQuery, so sorry if this is an easy question.  I've looked around but haven't found any examples for this.</p>

<p>Here's the JQuery code:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(function () {

        //Modal pop-up form
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $("#dialog:ui-dialog").dialog("destroy");

        var email = $("#email"),
                allFields = $([]).add(email);
                tips = $(".validateTips");

        function updateTips(t) {
            tips
                    .text(t)
                    .addClass("ui-state-highlight");
            setTimeout(function () {
                tips.removeClass("ui-state-highlight", 1500);
            }, 500);
        }

        function checkLength(o, n, min, max) {
            if (o.val().length &gt; max || o.val().length &lt; min) {
                o.addClass("ui-state-error");
                updateTips("Length of " + n + " must be between " +
                        min + " and " + max + ".");
                return false;
            } else {
                return true;
            }
        }

        function checkRegexp(o, regexp, n) {
            if (!(regexp.test(o.val()))) {
                o.addClass("ui-state-error");
                updateTips(n);
                return false;
            } else {
                return true;
            }
        }

        $("#dialog-form").dialog({
            autoOpen: false,
            height: 350,
            width: 350,
            modal: true,
            buttons: {
                "Send Login": function () {
                    var bValid = true;
                    allFields.removeClass("ui-state-error");

                    bValid = bValid &amp;&amp; checkLength(email, "email", 5, 80);

                    // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
                    bValid = bValid &amp;&amp; checkRegexp(email, /^((([a-z]|\d|[!#\$%&amp;'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&amp;'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "Please enter a valid email address.");

                    if (bValid) {
                        $("#users tbody").append("&lt;tr&gt;" +
                                "&lt;td&gt;" + email.val() + "&lt;/td&gt;" +
                            "&lt;/tr&gt;");
                        $(this).dialog("close");
                        $("form[name='modalPopup']").submit()
                    }

                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
                allFields.val("").removeClass("ui-state-error");
            }
        });

        $("#send-password")

                .click(function () {
                    $("#dialog-form").dialog("open");
                });


    });
&lt;/script&gt;
</code></pre>

<p>Here's the link that opens the form:</p>

<pre><code>&lt;strong&gt;Forgot your login?:&lt;/strong&gt; &lt;a href="#" id="send-password"&gt;click here&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>And here's the form:</p>

<pre><code>&lt;div id="dialog-form" title="Send My Login"&gt;
        Enter the email address associated with your account. Your password will be sent to you.
        &lt;br /&gt;
        &lt;strong&gt;If you do not have an email address&lt;/strong&gt;, or do not 
        remember it, please contact your Human Resources department to have your login 
        provided to you.

        &lt;p class="validateTips"&gt;&lt;/p&gt;

        &lt;form action="SendLogin.asp" method="Post" name="modalPopup"&gt;
        &lt;fieldset&gt;

            &lt;label for="email"&gt;Email&lt;/label&gt;
            &lt;input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" /&gt;

        &lt;/fieldset&gt;
        &lt;/form&gt;
    &lt;/div&gt;
</code></pre>

<p>Thanks a lot for any help!</p>
