+ Start a Discussion

Search by Enter key in Visual force page

I want to invoke the search functionality by pressing the search button or by clicking the enter key.


Its working fine for the input text fields, but not for the radio button.


I referred the http://developer.force.com/cookbook/recipe/submit-a-form-with-the-enter-key 


Attached is my code please help.

<apex:page controller="myCon" sidebar="true">
<script type='text/javascript'>
        function noenter(ev)  {
            if (window.event && window.event.keyCode == 13 || ev.which == 13) {
                return false;
             } else {
                  return true;

 <apex:form >
 <apex:pageBlock mode="edit">
    <apex:actionFunction name="doSearchAF" action="{!searchJobs}" />
       <apex:pageBlockButtons location="bottom">
         <apex:commandButton value="Search Jobs" action="{!searchJobs}" id="mybutton"/>
         <apex:commandButton Value="  Clear  " action="{!cancel}" onclick="return confirmCancel()" />
            <apex:pageBlockSection columns="1">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="State" for="state" styleClass="textFont"/>                  
                    <apex:inputText value="{!state}" id="state" onkeypress="return noenter(event);" />

                <apex:pageblocksectionItem >
                    <apex:outputLabel value="Job Type" for="jt"/>
                    <apex:outputPanel id="jt">
                         <apex:selectRadio value="{!SelectJobType}" onclick="return noenter(event);">
                             <apex:selectOptions value="{!jobType}"/>