Click here to Skip to main content
15,885,309 members
Articles / Web Development / ASP.NET

how to remove previous text when user enter a new number or character and start typing in javascript or jquery

Rate me:
Please Sign up or sign in to vote.
2.00/5 (1 vote)
4 Nov 2012CPOL 4.7K  
I have a textbox ,i want whenever user start entering a number in that texbox the previous value should be remove.Let say there is a textbox which contain a number as 23 ,i want whenever user start typing in that same textbox 23 shold be remove and new enetered number should be shown.My...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
4 Nov 2012Sergey Alexandrovich Kryukov
To start with, if you are already using jQuery, document.getElementById is not needed, as you can use jQuery selectors:http://api.jquery.com/category/selectors/[^].Now the solution: text box is actually the input element with the attribute type="text". For all input elements, its value is...
Please Sign up or sign in to vote.
6 Nov 2012deepak.m.shrma
Try this its working fine :-) $(function () { $("#mytext").focus(function () { var keyPressed = false; $("#mytext").keypress(function () { // alert("Handler for .keypress() called."); keyPressed = true; ...
Please Sign up or sign in to vote.
4 Nov 2012Al Moje
Hi,Try this if could help...$(document).ready(function() {$("#mytextbox").focus(function() {if($("#mytextbox").val() != "") $("#mytextbox").val(""); });});Do not forget to mark as answer if could help...Regards,

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Syscon Infoway Pvt. Ltd.
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions