Find textbox length in javascript

In this tutorial,I will explain how to find the length of textbox using javascript.It is very easy to find textbox length in javascript.we can use javascript length property.

Example:Find textbox length in javascript
<html>
<head>
<title>Textbox limit characters</title>
<script>
function findTextboxLength()
{
textbox_val=textbox1.value;//gets the value of the input element entered by the user.
    textbox_length = textbox_val.length;//find the length of textbox in javascript
    if (textbox_length < 10)
    {
        char = 10 - textbox_length;
        msg = char + " characters left";
        text_span.innerHTML="<font color=blue>" + msg + "</font>";
    }
    else
    {
        text_span.innerHTML="<font color=red>Message is too long</font>";
    }
 }
</script>
</head>
<INPUT type="text" id="textbox1" onKeyUp="findTextboxLength();" >
<span id="text_span" name="text_span"></span>
</html>