Tutorials » Javascript tutorials »

The string Object


This article explains about JavaScript 'String 'object




<html>

<head>

<script>

function f()

{
v =document.getElementById('txt');

alert(v.value.length);

}


</script>

</head>

<body>

Enter Text and click on button to get lengh:<BR>

<input type ="text" id ="txt">

<input type ="button" value ="Click" onclick ="return f();" >

</body>

</HTML>



The output is self explanatory. It takes the input string and calculates the lengh.

The main purpose of length validation in real time is used in following cases.

  • To check length of password field, minimum as 7 characters maximum 25
  • To check Userid length id the length is not in the specified range and fire validation message
  • To force user to enter in textboxes when it's a mandatory field or any other fields length checking




  • Next Chapter: The Date Object
    Previous Chapter: The JavaScript String object
    More Chapters: Javascript Tutorials
    More Tutorials: Tutorial Index



    Top Contributors
    Today
      Last 7 Daysmore...

      Awards & Gifts

      Online Members

      More...
       
      Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India