JSF验证对话框表单

I have a dialog form popup when I click one button, this form is used to create a new school record with just one field. I have add required validation to this only input field, and everything works fine, but the only thing I don't know how to do is when I click submit, whatever form validate or not, the dialog will dismiss by following code:

 initDataTable();
    // Dismiss the dialog
    $('#dialogNewSchool').dialog('close');

before the dialog close, I should put the form validation check (something like the return from validation class), how I can do this in javascript? I'm using JSF 2.1 implementation.

Btw, I don't want to use client side validation, because not only required validation needed for this field.

Thanks. ;)

If I got you right you want to keep dialog open in case of validation errors?

Than you can add the following code somewhere in your page

<h:panelGroup id="global_flag_validation_failed_render">
    <h:outputText id="global_flag_validation_failed" value="true" rendered="#{facesContext.validationFailed}"/>
</h:panelGroup>

And upon clicking your submit button render the above block like this:

<f:ajax onevent="closeMyDialogIfAllOk" render="@form global_flag_validation_failed_render"></f:ajax>

and in your js code

function closeMyDialogIfAllOk(data){
    if(data.status === 'success') {
        if($("#global_flag_validation_failed").length === 0){
             $("#dialog_id").dialog("close");
        }
    }
}

For more info take a look over here: How to find indication of a Validation error (required=“true”) while doing ajax command