- Forums
- Javascipt
- How To Check How Many Characters In A String Javascript
This Page Contains information about How To Check How Many Characters In A String Javascript By wallpaperama in category Javascipt with 0 Replies. [814], Last Updated: Sat May 18, 2024
wallpaperama
Tue Jan 20, 2009
0 Comments
1492 Visits
length
if you want to know how many characters a string has or a variable (var) in javascript you can find that information by using the str.length in your javascript. for example, lets say i have a variable called wallpaperama:
var string= 'wallpaperama';
wallpaperama.html
<script language="javascript" type="text/javascript">
var string= 'wallpaperama';
alert(string.length);
</script>
if you run that script, you will get a popup windows says: 12
the best way to learn is to actually do it so if you want to try it and give it a test run, open a text editor like notepad, copy and paste the code above and save the file as wallpaperama.html then open it with your browser and see it in action. its much more fun that way. but if you are a lazy bum, i will show you a demo