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
ckellieckellie 

How do I change this Javascript function?

I have found  javascript function that saves the visualforce page:

 

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

 Field functionality:

        <apex:inputfield value="{!PCN__c.Account__c}" label="Customer Name" required="true" onkeypress="return noenter(event);" styleclass="searchStr"  />

 How do I change the javascriptt from saving the record to advancing the cursor from one field to the next field?

Thank you

Best Answer chosen by Admin (Salesforce Developers) 
SarfarajSarfaraj

I am giving one example using standard object Account.

<apex:page standardController="Account">
<script type='text/javascript'>
    function noenter(ev, nextelementid)  {
        if (window.event && window.event.keyCode == 13 || ev.which == 13) {
            document.getElementById(nextelementid).focus();
            return false;
         } else {
              return true;
         }
     }
</script>
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:inputField id="name" value="{!Account.Name}" onkeypress="return noenter(event, '{!$Component.phone}');"/>
            <apex:inputField id="phone" value="{!Account.Phone}" onkeypress="return noenter(event, '{!$Component.website}');"/>
            <apex:inputField id="website" value="{!Account.Website}" onkeypress="return noenter(event, '{!$Component.name}');"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

 

All Answers

SarfarajSarfaraj

I am giving one example using standard object Account.

<apex:page standardController="Account">
<script type='text/javascript'>
    function noenter(ev, nextelementid)  {
        if (window.event && window.event.keyCode == 13 || ev.which == 13) {
            document.getElementById(nextelementid).focus();
            return false;
         } else {
              return true;
         }
     }
</script>
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:inputField id="name" value="{!Account.Name}" onkeypress="return noenter(event, '{!$Component.phone}');"/>
            <apex:inputField id="phone" value="{!Account.Phone}" onkeypress="return noenter(event, '{!$Component.website}');"/>
            <apex:inputField id="website" value="{!Account.Website}" onkeypress="return noenter(event, '{!$Component.name}');"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

 

This was selected as the best answer
ckellieckellie
This works, Thank you