when use generic alert box form validation works ok if try make alert box nice using jquery script form validates , submits despite value returned being false
the standard alert box works
function validate(){ if( document.audit_form.audit_name.value == "" ) { alert( "please select name audit" ); document.audit_form.audit_type.focus() ; return false; } return true; }
attempt 1 jquery msgbox codecanyon
function validate(){ if( document.audit_form.audit_name.value == "" ) { $.msgbox("please select audit type", { type:"alert", buttons: [ {type: "submit", value: "ok"} ] }, function(result){ if (result && result=='ok'){ return false; } }); } return true(); }
attempt 2 apprise
function validate(){ if( document.audit_form.audit_name.value == "" ) { apprise('please enter name audit?', {'textok' : 'ok',}, function(r) { if(r) { return( true ); } else { return (false); } }); } }
in 3 instances alert box displays when should jquery versions form still submits. functions called using
<form id="audit_form" name="audit_form" method="post" enctype="multipart/form-data" action="<?php echo $_server['php_self']; ?>" onsubmit="return validate();">
both $.msgbox
, apprise
not blocking functions , result returned before functions' callback, should change logic. that's how form submit should like:
$('#audit_form').submit(function(event){ event.preventdefault(); youruialertfunction(..., ..., function(issuccess){ if(issuccess){ submitformlogic(); } else { hidealertandshowerrors(); } }); });