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

JavaScript - OnClick Select All the Text from Textarea or Textbox Controls

Mar 14, 2013

Here I will explain how to select all the text by click on textarea or textfield using JavaScript or Highlight All Text by Clicking on Text Field or Textarea in JavaScript.

In previous article I explained how to set watermark text for textbox using JavaScript, Remove duplicate values from string array in JavaScript, Disable drag and drop options in textbox or textarea controls, JavaScript show number of characters left in textbox and many articles relating to, jQuery, JavaScript. Now I will explain how to select all the text by click on textarea or textbox field using JavaScript.

To implement this we need to write the code as shown below

<html xmlns="">
<title>Javascript onclick select all textarea</title>
<script type="text/javascript">
function SelectAll(id) {
Enter Text:<br/>
<input type="text" id="txtfld" onclick="SelectAll('txtfld');" style="width:200px" value = "This text you can select all" /><br />
<textarea rows="5" cols="23" id="txtarea" onclick="SelectAll('txtarea');" style="width:200px" >Hi, Welcome to I hope this site will give you better info </textarea>
Live Demo

To check for live demo try to put cursor in below textbox or textarea



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

Get the latest,, 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


Veersh Dachepally said...

Very Good Articles......I like So Much....Very Helping to us

Unknown said...

it is not working in gridview textbox
please help


Give your Valuable Comments

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

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