Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Clear Textbox Value on focus

Apr 30, 2013
Introduction

Here I will explain How to use jQuery to clear textbox value on focus or simple jQuery code snippet to clear textbox value onfocus using jQuery.

Description:
  
In previous posts I explained jQuery to clear textbox value, jQuery get set textbox value, jQuery disable cut copy and paste options in textbox, jQuery Create Rounded Corners Textbox and many articles relating to JQuery, JavaScript, Asp.net. Now I will explain how to clear textbox value onfocus using jQuery.

Bind focus event for all textboxs to clear values onfocus using jQuery

$(function () {
$('input[type=text]').focus(function () {
$(this).val('');
})
})
To clear Particular textbox onfocus using jQuery

$(function () {
$('#txtuser').focus(function () {
$(this).val('');
})
})
For complete example check below code


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Clear Textbox onfocus using jQuery</title>
<script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('input[type=text]').focus(function () {
$(this).val('');
})
})
</script>
</head>
<body>
<div>
<b>Enter Text:</b>
<input type="text" id="txtuser" value="Welcome to Aspdotnet-Suresh.com" />
<input type="text" id="txtName" value="Aspdotnet-Suresh.com" />
</div>
</body>
</html>

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

5 comments :

Anonymous said...

i want to create gallery of albums based on date.

data stored in sql table..table containing following fields

1.picture path

2.picturediscription

3.date

i want to display as different albums based on date....

how to do this..?

Ravi Pandit said...

i want to do in MVC pls upadte ?

Anonymous said...

kl

Unknown said...

how it can be implemented in asp. net textbox

sanju said...

just copy and paste the content, its will work
note: only runat="server" dont replace it.

Very nice code

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.