How to call apex method on enter key press in Salesforce?

Sample Code:

<apex:page>

<script type='text/javascript'>
    function noenter(ev)  {
        if (window.event && window.event.keyCode == 13 || ev.which == 13) {
            callAcctRet();
            return false;
         } else {
              return true;
         }
     }
</script>

<apex:form>
    <apex:actionFunction action="{!retToAcct}" name="callAcctRet"/>
    <apex:inputText value="{!firstName}" onkeypress="return noenter(event);"/>
    <apex:form>
</apex:page>

Cheers!!!

No comments:

Post a Comment