0

I have a javascript validation on click of command button(onclick="return validationFunc();"). When the validation is failing the backend action is not getting called(which is expected),however the action does not get called when the validation is passing.

<apex:commandbutton onclick="return validationFunc();" action="{!backendAction}"/>

function validationFunc(){
//when validation fails
return false;
//when validation passes
return true;
}

1 Answer 1

1

This will not work together. Refer to this answer: Visualforce onclick doesn't execute action or rerender

You would have to create Action Function to achieve desired functionality.

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

<apex:commandButton onclick="validationFunc();"/>

JS

function validationFunc(){
//when validation pass
backendAction();
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .