How to find indication of a Validation error (required=“true”) while doing ajax command

前端 未结 4 1621
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 22:45

I have a form inside a dialog which I close by clicking on commandbutton with ajax ,

like this



        
4条回答
  •  盖世英雄少女心
    2020-11-29 23:09

    Two things 1) Checking for an error in the 'onevent' function

    Surely you have a message tag for the mandatory field?

    
    

    So you can check for the error-class something like

    var message = $('#m-my-field-id');
    
    if(message.hasClass('error-class'){
        //do this
    }
    else{
      //do that
    }
    

    2) The DOM isn't up to date on success

    Yes, I can see the message on the page in Firefox, yet jQuery tells me it is not there.

    I have found that using the smallest possible timeout is sufficient to fix this

    setTimeout(
        function(){
        setErrorStyle(source.attr('id'));
        },
       1
    );
    

提交回复
热议问题