お問い合わせフォームがあり、ユーザーが [送信] をクリックすると、ダイアログ ボックスが開き、[OK] をクリックすると、フォームが送信されます。ただし、[OK] をクリックすると、ダイアログ ボックスが閉じられるだけで、フォームは送信されません。ここに行くとコードをテストできます。
Javascript/jQuery: //
function go_there(){
$.prompt('<b>DISCLAIMER</b> <span style="font-weight:normal">TEXT WILL GO HERE</span>',{
buttons: { Ok: true, Cancel: false},
callback: function(e,v,m,f){
if(v){
$('#email').submit()
}else{
}
}
});
}
//]]>
</script>
HTML: //
<form method="post" action="nlphpmail.php" id="email">
<input type="hidden" name="subject" id="subject" value="Feedback form" />
<fieldset>
<div class="formfield">
<label class="text title" for="contact_who">Name</label>
<input type="text" class="text required" name="contact_who" id="contact_who" value="">
</div><!-- /.formfield -->
<div class="formfield">
<label class="text title" for="contact_sendto">Email address</label>
<input type="text" class="text required email" name="contact_sendto" id="contact_sendto" value="">
</div><!-- /.formfield -->
<div class="formfield">
<label class="text title" for="contact_phone">Phone</label>
<input type="text" class="text required" name="contact_phone" id="contact_phone" value="">
</div><!-- /.formfield -->
<div class="formfield">
<label class="text title" for="contact_message">Message</label>
<textarea name="contact_message" class="required" id="contact_message"></textarea>
</div><!-- /.formfield -->
</fieldset>
<div class="formfield">
<button class="button" id="submit" value="send" type="button" name="submit" onClick="go_there();">Send</button>
</div>
</form>