I've found a very serious bug in eBase which I have been able to reproduce in a new form.
When you press enter in a text field, the focus jumps to the button and triggers its click event.
You can reproduce this by creating a new project, add a field and a button and run the application. Click on the text field press enter. The focus jumps to the button which is clear because it is has an orange border indicating that it has the focus. This will also trigger the click event script if there is one assigned.
Please advise me if there is a way to disable this behavior but it causes unwanted side effects
Pressing enter in a text box submits the form
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
What you're seeing here is the default behaviour of most, but not all, browsers. They interpret the enter key as meaning a submit of the form and do this by "clicking" the next button. Seeing as how this is common web behaviour, many people expect this so you should be a little bit careful about removing it.
You can suppress this behaviour by adding the following Javascript to a page. If you want to do this for all forms, it's probably easiest to create a client script and add this to the presentation template. This uses jQuery so the jQuery core javascript also needs to be loaded.
Here's an alternative version found online that doesn't use jQuery:
You can suppress this behaviour by adding the following Javascript to a page. If you want to do this for all forms, it's probably easiest to create a client script and add this to the presentation template. This uses jQuery so the jQuery core javascript also needs to be loaded.
Code: Select all
$(document).keypress(function (e) {
if(e.which == 13 && e.target.nodeName != "TEXTAREA") return false;
});
Code: Select all
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey;
0 x
Who is online
Users browsing this forum: No registered users and 5 guests