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

  • Home
  • SEARCH
  • 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 8297039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:15:13+00:00 2026-06-08T15:15:13+00:00

I m working on a web application that contains a text box. The value

  • 0

I m working on a web application that contains a text box. The value of text box is filled from Date picker and its property is read only by default. till now everything is working fine. But problem occurs when I press backspace button. Rather than clearing the text box it is redirecting me back on the previous page.

i handled this situation by a javascript function by referring some previous answers on this site.

 function allowBackSpace(val) {
    var keyCodeEntered = (event.which) ? 
                             event.which : 
                             (window.event.keyCode) ? 
                                 window.event.keyCode : 
                                 -1;
    if (keyCodeEntered == 8) {
        $(this).val(""); 
        return true;
    }
    return false;
   }

UPDATE : this function is called from

<asp:TextBox ID="txtDate" 
             Style="margin-left: 5px; margin-right: 5px" 
             runat="server"
             Width="88px" 
             onkeypress="return allowBackSpace(this);">
</asp:TextBox>

I m calling this function on key press event of the textbox. The preoblem is that it is allowing only to delete one character at a time.

I wish to clear the whole textbox if user presses backspace button. Stuck here as how to achieve this.

Thanks in advance
Akhil

PS:Any way to achieve this using C# code will also be very helpful.

  • 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-06-08T15:15:15+00:00Added an answer on June 8, 2026 at 3:15 pm

    You are returning true from js function, which also performs its keypress event. So, try with returning false.
    You can try the following code:

    function allowBackSpace(val) {

    var keyCodeEntered = 
         (event.which) ? event.which : 
                     (window.event.keyCode) ? window.event.keyCode : -1;
    if (keyCodeEntered == 8) 
    {
         $(this).val("");
         return false;
     }
     return false; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i m working on a web application that reads files from some where and
I'm working on an application that gets information from a fixed web page and
I am working on a legacy application that contains references to two .asmx web
I am currently working on an advanced web application that contains a number of
I'm working with a legacy WebLogic application that contains a web-service application and a
I am working on web application that will use PHP & MySQL. Application will
I'm working on a web application that submits tasks to a master/worker system that
I'm working on a web application that has a lot to download (javascript, images,
I am working on a web application that is consuming a Dataset returned by
I'm working on a web application that will have a custom UI for the

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.