Get character length of input element value using jQuery

You can length (number of characters) an input element value with the help of length function. The example of length method mentioned below: Code


<html>

  <body>
     <input type='text' value='Good Morning' id='inputElem'>>  
    <script language='JavaScript' type='text/Javascript'>
      var result = $('#inputElem').val().length();
    </script>
  </body>
</html>
Output

'result' variable's value would be '12'