Multiple Form Elements + ENTER key
Hi -
We're running into some user issues where they are wanting to hit the ENTER key after inputting text into one of three different form fields on a page. We have the following:
- Newsletter Signup box (Constant Contact)
- Sitefinity search box
- Store Locator zip code / address form
I'm trying to think of a way to allow the user to use their ENTER key but have the focus be on whatever form element they are trying to fill out. I tried creating an iframe for the newsletter signup box, however now the SF search box is triggered when using the ENTER key on the zip code lookup box. Any help or ideas would be greatly appreciated!
Thanks,
Greg
Hi,
I tried achieving this only with jquery but it turned out to be impossible. This is because each widget renders different HTML and even if we select the current focused element (which I was able to do), there is no way to define which is the relevant button for this widget (the only way would be to hardcode selection of some wrapper divs by class and find the button from their child elements, but this wouldn't work well).
So, I came to the conclusion that the only way would be to map template for each of the relevant widgets and in the server code add the jquery selection code, together with the Client ID of the widget. The code should be similar to this:
TextBox1.Attributes.Add(
"onkeydown"
,
"if(event.which || event.keyCode)if ((event.which == 13) || (event.keyCode == 13)) document.getElementById('"
+Button1.UniqueID+
"').click();return false; else return true; "
);
Hi Svetoslav -
Can you expland on what you meant by "map template for each of the relevant widgets"? I know some of the widgets have an advanced settings area where you can map external templates, but how could this be done with the Sitefinity search box?
Thanks,
Greg
Hello,
All of the widgets' templates can be mapped by doing the following:
Go to Administration >> Settings >> Advanced >> Controls >> ViewMap and create a new map, for example for the Search box:
HostType: Telerik.Sitefinity.Services.Search.Web.UI.Public.SearchBox
LayoutTemplatePath: ~/Controls/MyTemplate.ascx (the virtual path to your .ascx template in the solution)