Here is the code snippet I am working on:
<asp:Panel runat="server" ID="divNoPolicyId" class="divDSBox" ChildrenAsTriggers="false" UpdateMode="Conditional">
<telerik:RadTextBox ID="PolicyIdInput" runat="server" Width="75px" EmptyMessage="Policy Id" style="margin-left: 3px; margin-bottom: 7px;" onkeyup="checkForChars(this, event)"></telerik:RadTextBox>
<telerik:RadButton ID="GoButton" runat="server" Skin="Vista" ButtonType="StandardButton" Text="Go" style="margin-left: 5px; margin-top: 5px;" Enabled="False" CausesValidation="false">
<Icon SecondaryIconCssClass="rbNext" />
</telerik:RadButton>
</asp:Panel>
Whenever I focus on the input box and press enter, the page reloads which I want to prevent. I have tried capturing the event and preventing default behavior in JavaScript using this function:
function checkForChars(textBox, event) {
console.log(event);
event.preventDefault();
}
I have also attempted to redirect the form's default submit action to a dummy button like so:
<asp:Panel runat="server" ID="divNoPolicyId" class="divDSBox" DefaultButton="DontReload">
<asp:Button runat="server" Style="display: none" ID="DontReload" disabled="true"/>
...
</asp:Panel>
Unfortunately, none of these solutions have worked for me. Despite searching for answers, I have not found a suitable solution to my problem.
My background is more focused on modern front-end technologies where handling events and calling preventDefault() usually resolves similar issues.