jQuery basic help calling a dialog when a give class is listed
===

I have this situation:
I have a page where I can edit users info(name, email, phone, etc...). when I click on the edit button, it calls a dialog (modal window), that loads the user data that is already set in the database.
When the user click on the Update button, I do a verification in my controller to make sure he inserted a valid e-mail. If the e-mail is not valid, I have an error and I add a class named "error" into the html label, in this specific dialog. What I'm trying to do is, if there's a mistake, I want the dialog to open right after the verification. As I have this specific class error set only when and where there's a mistake, so I want your help to find a way to call the dialog `$('#addEditUserDialog').dialog('open');` when this condition : `$("#addEditUserDialog label.error")` happens.

I tried doing:

    if ($("#addEditUserDialog label.error")) {
            $('#addEditUserDialog').dialog('open');
        }

but it's calling the dialog even if the class error isnot set.
I know it's a basic question, but I have not much experience with javascript and I'm kind of lost.



   