[jQuery] Dialog (jQuery UI Dialog) closes when i cancel a form submission

[jQuery] Dialog (jQuery UI Dialog) closes when i cancel a form submission


i have a form inside dialogs. i use ajaxForm plugin for my forms. i
validate using beforeSubmit ... like in the example below. the strange
thing is the dialog closes in the Add/Edit Type forms but not in the
Add/Edit Category. the form did not submit which means the return
false works but the dialog containing the form closes. why is this so?
$("#frmAddType").ajaxForm({
dataType: "json",
    beforeSubmit: function() {
        if ($("#atName").val() == "") {
            alert("Please enter a type");
            return false;
        }
    },
success: postAddType,
resetForm: true
});
$("#frmEditType").ajaxForm({
dataType: "json",
    beforeSubmit: function() {
        if ($("#etName").val() == "") {
            alert("Please enter a type");
            return false;
        }
    },
success: postEditType,
resetForm: true
});
$("#frmAddCategory").ajaxForm({
dataType: "json",
    beforeSubmit: function() {
        if ($("#acName").val() == "") {
            alert("Please enter a category");
            return false;
        }
    },
success: postAddCategory,
resetForm: true
});
$("#frmEditCategory").ajaxForm({
dataType: "json",
    beforeSubmit: function() {
        if ($("#ecName").val() == "") {
            alert("Please enter a category");
            return false;
        }
    },
success: postEditCategory,
resetForm: true
});
});