Javascript Form How to - Handle TextArea mouse up action event








Question

We would like to know how to handle TextArea mouse up action event.

Answer


<html>
<head>
<script type="text/javascript" language="javascript">
function CheckStatus(){<!--from   www.j  av a 2  s  .c  om-->
    if (document.MyForm.MyTextField.value==""){
        console.log("First please enter your name");
        document.MyForm.MyTextField.focus();
    } else{
        document.MyForm.Comments.select();
    }
}
</script>
</head>
<body>
<table>
<form name="MyForm" action="" method="Post">
<tr>
 <td><input type="text" name="MyTextField"/></td>
 <td>Enter your name</td>
</tr>
<tr>
 <td><textarea name="Comments" rows="6" cols="40" onmouseup="CheckStatus()" >Please enter your name first</textarea></td>
 <td>Enter your comments.</td>
</tr>
<tr>
 <td><input type="submit" value="Click to Submit"/></td>
 <td>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

The code above is rendered as follows: