i'm working with primefaces commandButton with onclick and action, i want to prevent onclick from execute action method when onclick function return false
CommandButton :
<p:commandButton value="calc"action="#{bean.actionMethod()}" oncomplete="DataReturn(xhr, status, args)" onclick="javaScriptOnclickmethod();">
</p:commandButton>
JavaScript :
function javaScriptOnclickmethod(){
var code = document.getElementById("form:idS").value;
if(code.trim() !== '') {
return true;
} else {
return false;
}
}
what should i do to stop on the onlick function when returning false