I have a apex function that does not seem to care about the javascript return value. Why?
<script>
function validate() {
var result = false;
var inp = document.querySelector('[id$="srchText"]').value;
if(inp.length < 3) { showErrMsg(); }
if(inp.length > 2) { showSrchResults(); result=true; }
return result;
}
<apex:commandLink value="Search Cases" styleClass="btn" style="text-decoration:none;padding:5px;" onclick="validate();" action="{!srchCases}"/>
If the return result is false the action should not be called. If right after the onclick="validate();" I put return false ie (onclick="validate(); return false;" the apex action method does not get called. Why does the commandlink onclick action ignore the return results from the javascript and how do I get it to accept the return results?