ZeroShade Posted June 27, 2007 Share Posted June 27, 2007 I have an asp textbox on my masterpage used for searching throughout the site. However, if the user is to push enter at any time the default textbox selection is always that search box. How can I keep this text box from being selected if the user accidentally pushes enter on the page? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 27, 2007 Share Posted June 27, 2007 I believe that the enter button will submit whichever form has focus, and I believe that when the page initially loads it will give the first form focus, even if it hasn't been clicked on. I'm not positive that that's how it works, but that's what I think. If so, you can add some Javascript to remove focus from the form. Make sure you give an ID to your textbox so that Javascript can reference it. <script type="text/javascript">document.getElementById("textbox_id").blur();</script> Add that to the bottom of the page. Link to comment Share on other sites More sharing options...
ZeroShade Posted June 27, 2007 Author Share Posted June 27, 2007 It doesn't work... is there another way? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 27, 2007 Share Posted June 27, 2007 Well that's how you blur a form element, I don't know if there is another method for removing the enter key's functionality. Check Google.http://www.google.com/search?hl=en&cli...amp;btnG=Search Link to comment Share on other sites More sharing options...
ZeroShade Posted June 28, 2007 Author Share Posted June 28, 2007 Thanks... that should help! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.