function ValidateField(){
var bAllow= true;
//some checking here
if (bAllow == true && apl.val().trim() == "")
{
showDialog();
showDialog().done(function() {
return true; // wanna return true, but not success
}).fail(function() {
return false; //wanna return false, but not success
});
return false; //stop it to execute to next line
}
return bAllow; //success return }
function showDialog(){
var def = $.Deferred();
var modPop = '<div id="diaCom" title="Information?"><p>something something</p></div>';
$("#diaCom").remove();
$(modPop).appendTo('body');
$("#diaCom").dialog({
resizable: false,
draggable: false,
height:150,
width:300,
modal: true,
buttons: {
"Ok": function() {
def.resolve();
$(this).dialog("close");
},
"Cancel": function() {
def.reject();
$(this).dialog("close");
}
}
});
return def.promise();
}
//on click
if (validateField() == true){
//do something
}else{
//do something
}
hi everyone, any chance to return the value? I wish to return the true and false through showDialog().done() and fail for validatefield() function, but it not working as what I want, I can't assign to bAllow as I had already have a return false to hold the dialog to execute its next line, any idea? Or it is correct to do like these?
return
later. I'm not sure how to "fix" this, but I think the way is to reorganize your code/logic – Overwork$("#theform")[0].submit();
– Characteristic