function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sandy singhSandy singh 

on hit enter call submit button

Hi,

 I have 2 buttons one is previous & other is submit on same visualforce page and its contain multiples fields, on hit of Enter button its invoke submit  not previous button. In my case below code invoke submit button only once hit enter button for filed

 of  " <apex:inputField value="{!account.age}" required="true" id="provider" onkeypress="return noenter(event);"/>"   

Once onfocus go to next filed this doesn't work.

 

Code:

<apex:page>
<script>
function noenter(ev)  {
        if (window.event && window.event.keyCode == 13 || ev.which == 13)
         {
            var ele=document.getElementById('{!$Component.pifBioForm.pifPageBlock.a.b}');
            ele.click();
            return false;
         }
         else
         {
            return true;
         }
          }
</script>

<apex:form id="pifBioForm"  >
        
        <apex:pageBlock title="My Details" id="pifPageBlock">  
            Fields marked with (<B><font color="red">|</font></B>) are required. <br />
            <apex:pageMessages escape="false" />

            <apex:pageBlockButtons id="a">
                <apex:commandButton id="c" action="{!pifTripPageTwo}"  value="Previous" / >&nbsp;&nbsp;&nbsp;
             <apex:commandButton id="b" action="{!validateDateExpiry}" value="Submit" /> 
            </apex:pageBlockButtons>

<apex:pageBlockSection>
 <apex:pageBlockSectionItem id="p">
                    <apex:outputLabel value="Name Provider" />
                    <apex:inputField value="{!account.age}" required="true" id="provider" onkeypress="return noenter(event);"/>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem id="groupSecItem">
                    <apex:outputLabel value="Ph Number" />
                    <apex:inputField value="{!account.phnumber__c}" id="phnumber" />
                </apex:pageBlockSectionItem>

</apex:page>

 

Please help me on this.

 

Thanks ,

Sandy