CancelImage Upload

How to focus on or blur a textarea or other form object via JavaScript

To focus on, or blur the curser from a form element in JavaScript is simple. All that you need is the following two functions.



As you can see the functions focus() and blur() need to be called upon at the end of the dom objects specified path. In this instance we are using getElementById() to access the textarea. As you can see there is nothing complex about these two functions. Indeed, all that is needed is correct path specifications. Here is another example:

<title>How to focus on or blur a textarea or other form object via JavaScript</title>
<script language="javascript">

function textareaFocus()



function textareaBlur()




<textarea id="textarea1"></textarea><br>
<input type="button" onclick="javascript:textareaFocus();" value="Focus">
<input type="button" onclick="javascript:blur();" value="Blur">


Want to leave a comment?

No problem. Just enter your email and password below.

register | home | reminder

myDesignTool Networking •