I am trying to make my form display a dialog box (possibly via Javascript) upon successful submission of my form. How do I do this?
JS
<script type="text/javascript">
$.validator.setDefaults({
});
$().ready(function() {
// validate alphaRegister form on keyup and submit
$("#alphaRegister").validate({
rules: {
email: {
required: true,
email: true
}
},
messages: {
email: "*"
}
});
});
</script>
HTML
<form id="alphaRegister" action="src/php/newSubscriber.php" method="post">
<input type="email" name="email" id="cemail" value="" class="required" />
<div style="float:right; margin:0 5px 2px 0;"><input type="submit" id="submit" name="submit" value="" /></div>
</form>
Use your server side script to add a JS variable to your page once the form has been submited/processed and then in your
$().readyfunction, check to see if this variable is set. If it is then display your dialog box.Update:
To do this you will need to set a PHP variable
formSubmitResultto true/false or 1/0 if it passes/fails your PHP validation routine.Then put this in the head of the page that you submit to: