This script highlight/select all text of textarea or text field when on click.

Code Snippet

function SelectAllText(text_control)  
{      
	text_control.focus();
	text_control.select();  
}

Sample Usage

<textarea onclick="SelectAllText(this);" style="width:150px" >When you click here, all text within control will be selected.</textarea>
<input type="text" onclick="SelectAllText(this);" style="width:150px" value = "Click here to select me" />


author's photo

Author : Blue Cloud

Just a normal software developer who love to write code. Developing professional software since 1999. After working in the software industry for many years, I've started my own website to share knowledges and experiences.

COMMENTS
blog comments powered by Disqus