Recipes by Category
App Distribution (2)
Bundle logic, interface and services for distribution.
App Logic (37)
The Apex programming language, workflow and formulas for logic.
Collaboration (6)
The Salesforce Chatter collaboration platform.
Database (29)
Data persistence, reporting and analytics.
Integration (33)
Web Service APIs and toolkits for integration.
Security (9)
Platform, application and data security.
Tools (4)
Force.com tooling
User Interface (36)
Visualforce MVC and metadata-drive user interfaces.
Web Sites (12)
Public web sites and apps with optional user registration and login.
Cookbook Home » Submit a Form with the Enter Key
Share
X
Vote to Verify a Recipe
Verifying a recipe is a way to give feedback to others and broaden your own understanding of the capabilities on Force.com. When you verify a recipe, please make sure the code runs, and the functionality solves the articulated problem as expected.
Please make sure:- All the necessary pieces are mentioned
- You have tested the recipe in practice
- Have sent any suggestions for improvements to the author
Please Log in to verify a recipe
You have voted to verify this recipe.
© Copyright 2000-2013 salesforce.com, inc. Web-based Customer Relationship Management (CRM) Software-as-a-Service (SaaS).
All rights reserved Various trademarks held by their respective owners.
All rights reserved Various trademarks held by their respective owners.
Salesforce.com, inc. The Landmark @ One Market, Suite 300, San Francisco, CA, 94105, United States
General Enquiries: 415-901-7000 | Fax: 415-901-7040 | Sales: 1-800-no-software
General Enquiries: 415-901-7000 | Fax: 415-901-7040 | Sales: 1-800-no-software

Recipe Activity - Please Log in to write a comment
Is there a way to tweek this, so it will make the Enter key work as the Tab key?
The script works fine for me for inputText fields, i also have a radio button, if i select the radio button and enter it's not working any ideas on how to acomplish this one,
<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}"/> </apex:selectRadio> </apex:outputPanel> </apex:pageblocksectionItem>Working with Chrome v19
Verified - works with IE 6 and Firefox 3.6
The if statement i have that says
if($('.cWatchInput').val().length >= 3){
$('.cSearchBtn').click();
}
just checks to make sure the input field has more than 3 char and then forces a click on the button, but you can also just return true.
That code isnt supported cross browser, and there is a safty net you can use to make sure the defualt is prevented, you can do the following in jQuery
function noenter(e) {code = e.keyCode ? e.keyCode : e.which;
if (code.toString() == 13){
e.preventDefault();
if($('.cWatchInput').val().length >= 3){
$('.cSearchBtn').click();
}
}
}
There's another way that I can't take credit for thinking up that's remarkably similar, it seems to work in some situations where the above doesn't, such as text fields in forms that should have an action different than the default form submission (e.g. a search box):
<apex:inputText (your args) onkeydown="if(event.keyCode==13){this.blur();actionFunction();}" />