How to check that any error message is diplaying in visualforce page

i want to perform an action on onComplete event of commandbutton.I am calling javascript function ,in that function i want to know if there is any error displaying on visualforce page(Validation error).Can i implement this without using any controller.


I wonder if you can use the css class errorMsg of the error block:

enter image description here

If this class exists on the page – there is an error:

function checkIt(){
    if (jQuery('.errorMsg').length > 0){
        // Error exists
        alert('There is an error on the page!');
        alert('No errors!');

<apex:commandButton reRender="none" oncomplete="checkIt();" value="Click me"/>


Source : Link , Question Author : Pankaj , Answer Author : Sergej Utko

Leave a Comment