Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 467595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:35:51+00:00 2026-05-12T23:35:51+00:00

I have a textbox and whenever the user presses a key it’s checked to

  • 0

I have a textbox and whenever the user presses a key it’s checked to see if the user pressed enter. If the enter key is pressed, i want to add all the info in the textbox and transfer the user to a different url.

<script language="javascript" type="text/javascript">
    function checkEnter(e){ //e is event object passed from function invocation
        var characterCode;

        if(e && e.which){ //if which property of event object is supported (NN4)
            e = e;
            characterCode = e.which; //character code is contained in NN4's which property
        }
        else{
            e = event;
            characterCode = e.keyCode; //character code is contained in IE's keyCode property
        }

        if (characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
            var searchLink = '/Search/?Keywords=' + document.getElementById('<%= searchBox.ClientID %>').value;

            transferUser(searchLink);         
            return false; 
        }
        else{
            return true; 
        }
    }

    function transferUser(url) {
        window.location.href = url;
        window.location.replace(url);   
    }
    </script>

Search: <input name="ctl00$searchBox" type="text" id="ctl00_searchBox" class="header_line_search_box_textbox" onKeyPress="checkEnter(event);" />

I have tried every possible combination, but nothing happens. The site just refreshes itself.

I also need somehow to convert the text from the user to html safe, must like the HttpUtility.EncodeUrl in aspx.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:35:52+00:00Added an answer on May 12, 2026 at 11:35 pm

    I’m not sure you need all of this. Normal, built-in behavior for the following HTML markup does exactly as you want without the need for any JavaScript:

    <form method="get" action="/Search/">
        <input type="text" name="Keywords">
    </form>
    

    However, it is important that your UI have some sort of way to submit the form that doesn’t involve a key stroke. This is for two reasons:

    1. As Jorn pointed out, it might not be readily apparent that the key submits the form.
    2. Having no submit button may break usability for users who use alternative input devices.

    Because of the above reasons, the following is suggested:

    <form method="get" action="/Search/">
        <input type="text" name="Keywords">
        <input type="submit" value="Search or 'go' or whatever">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 300k
  • Answers 300k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the mkdir function. #include <sys/stat.h> #include <sys/types.h> int mkdir(const… May 13, 2026 at 7:56 pm
  • Editorial Team
    Editorial Team added an answer According to the javadoc, array() [1] returns the buffer's backing… May 13, 2026 at 7:56 pm
  • Editorial Team
    Editorial Team added an answer If you're trying to learn Zend Framework, I would recommend… May 13, 2026 at 7:56 pm

Related Questions

I have a textbox and whenever the user presses a key it's checked to
i've made a C# winforms application. Now i have a form which has lots
I have an ASP.NET user control that contains a text box control and a
I have a numeric textbox in C# .NET which is nothing more than a
Okay, so, this code is pretty basic. The user inputs an answer into a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.