I have an actionfunction called 'afterValidation' defined;

<apex:actionFunction name="afterValidation" action="{!prohibitedCountryCheck}" />

I am calling this function on 'Next' button;

<apex:commandbutton value="Next" onclick="showProhibitedCountryAlert(isProhibitedCountrySelected)"/>

<script  type="text/javascript">
        function showProhibitedCountryAlert(isProhibitedCountrySelected) {
            alert('isProhibitedCountrySelected = ' +isProhibitedCountrySelected);
            //alert('countryLookUpInfo = ' +countryLookUpInfo);
            if(isProhibitedCountrySelected) {
                alert('DO NOT create an Account that is located in any of the following countries ');
                //alert('After validation invoked');
            } else{afterValidation();}

But strangely, afterValidation() function isn't invoked in 'Chrome' though it works fine in IE. Why might that be, and how can I fix it?

  • Did you check the console for any error messages? – Adrian Larson May 22 '17 at 13:11
  • There are no error messages in the console. – Dilip May 23 '17 at 6:18

an apex:commandButton submits the form. This happens in parallel to the call to the onclick function, creating a race condition. See also http://salesforce.stackexchange.com/questions/29400/calling-apexactionfunction-on-apexcommandbuttons-onclick-event

if you use <input type="button"> it will most likely work. Interestingly it does not work for me using <button>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.