A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Engineering
»
HTML, CSS and JavaScript
Author
Count number of characters
Sapan Shah
Greenhorn
Joined: Jan 01, 2010
Posts: 24
posted
Jan 21, 2010 03:04:05
0
I want to count a number of dot(.) in a
string
which i am entering in a textfield.
<html> <head> <title></title> <script language="javascript" type="text/javascript"> function validate1() { var str=document.getElementById("web").value; count = 0; pos = str.indexOf("."); while (pos != -1) { count++; pos = str.indexOf(".",pos+1); } document.write(pos); } </script> </head> <body> <form action="" method="post" name="fm"> <input type="text" size="10" id="web" onblur="validate1()" value="www."><br/> </body> </html>
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35256
7
posted
Jan 21, 2010 03:20:37
0
I don't see a question in there ... does the code not work? If so, how does it deviate from what you expected it to do?
Android apps
–
ImageJ plugins
–
Java web charts
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
Jan 21, 2010 06:24:23
0
You can not use
document.write
after the page load.
Note: when you post code, please use code tags. Select the code and click the wonderful button that says "Code" on it.
Eric
I agree. Here's the link:
http://aspose.com/file-tools
subject: Count number of characters
Similar Threads
Submitting a text field along with a file?
command button issue
Not able to hide a sentence using jquery
radio button error problem?
Help with displaying data properly
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter