Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to envoke the BackSpace event in Javascript

Posted on 2006-07-05
7
497 Views
Last Modified: 2012-08-14
I have a texbox in my asp page. When the user enter some non-numerical value, it will pop up a message,

"Please Enter only Numbers".  Along with this message, I want to delete the non-numerical character entered by the user. In VB I use Sendkeys + {BACKSPACE}. When I give this command, it sends a backspace .

I want a similar option in Javascript. Any idea???
0
Comment
Question by:CWS (haripriya)
  • 4
  • 2
7 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 17041594
No. However you can cancel the event or chop the field to value.length-1

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17041613
0
 
LVL 7

Expert Comment

by:ljubiccica
ID: 17041714
Hey!

Well you probably have some function that checks the data given and then shout out some alert message???

In this case you can do something like this:

<script language="javascript">
function alert(){
alert('Enter the real stuff');
resetData();
}

function resetData(){
document.myinput.reset();
}
</script>

where the input you want clear must have the name you specified in document.myinput.reset();
(in this case you would have <input name="myinput">

Hope this is what you needed...

Ljubiccica
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17041768
@Ljubiccica - welcome to EE.
A few things:

There is no reset on field level...
Also you cannot access a field via document.fieldName
Please do not confuse people...
0
 
LVL 7

Expert Comment

by:ljubiccica
ID: 17041861
OK, i'm sorry...

i should have asked first where does cyberwebservice want to reset things...

i thought he wants to reset <input type="checkbox"> thing...

Sorry once again

Ljubiccica
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17042235
That is ok, however the code you proposed is not doing anything on any browsers regardless of what he wanted...
0
 
LVL 16

Author Comment

by:CWS (haripriya)
ID: 17200359
Sorry guys, no time for me to test your suggestions. I was tied up with other projects which doesnot use Javascript. I need some more time.

I just want to add coments to avoid this questions to get abondend.

I will check and get back to you soon.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question