CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Character counter

Print topic Send  topic

Author Message
Joe
Posted: 08/16/2004, 12:00 PM

I am creating a SMS application. You can only use 265 Character. I want to have the Message box (Textbox) only allow 265 characters. I can do this with Validation and that entire stuff fine. But want I also want is another textbox that is counting down from 265 so the user knows they have to start wrapping the message up. Any help would be great, Thanks

I am using
MS Access, CCS, .ASP
DonB
Posted: 08/16/2004, 5:26 PM

Use some client-side javascript: In the onkeyup event of the "input"
textbox (<INPUT> element), stuff the value of 265 - the "length" property
(that wll be the number of characters) into your other textbox.

Goto http://developer.netscape.com, then to the client-side scripting area.

--
DonB

http://www.gotodon.com/ccbth


"Joe" <Joe@forum.codecharge> wrote in message
news:6412104618ada2@news.codecharge.com...
> I am creating a SMS application. You can only use 265 Character. I want to
have
> the Message box (Textbox) only allow 265 characters. I can do this with
> Validation and that entire stuff fine. But want I also want is another
textbox
> that is counting down from 265 so the user knows they have to start
wrapping
> the message up. Any help would be great, Thanks
>
> I am using
> MS Access, CCS, .ASP
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

eiden


Posts: 34
Posted: 08/17/2004, 1:56 PM

<html>  
<head>  
  
<script language="javascript">  
  
function Lengde(text) {  
var letters 	= document.getElementById("counter");  
var max		= 265  
  
letters.innerHTML = text.length ;  
if (text.length >= max) {  
if(event != null && (event.keyCode == 8 || event.keyCode == 46)){  
event.returnValue = true;  
} else {  
event.returnValue = false;  
}  
} else {  
event.returnValue = true;  
}  
}  
</script>  
</head>  
<body>  
  
<textarea onkeydown="Lengde(this.value);" onkeyup="Lengde(this.value);" name="TextArea1" rows="10" cols="19"></textarea><br>  
  
<span id="counter">0</span> tegn [Max. 265]<br>  
  
</body>  
</html>

This is the HTML example code. You can adapt this to your page very easily.

The javascript prevents keyinputs in the textarea when the total length is over 265. But if you copy+paste, you can input more than 265 characters.

So to avoid this, use this code in the OnValidate event:

with formname  
  
.textarea.value = Trim(.textarea.value)  
  
If Len(.textarea.value) >= 265 then  
.errors.adderror("Textarea1 is too long")  
end if  
  
end with


I haven't tried the validation bit, so don't be suprised if there is a syntax error or two:-) (it's getting late here in Norway---:*))
View profile  Send private message
Suyog
Posted: 09/11/2004, 5:52 AM

I understood your code. But Actually let me tell you what exactly I need.

I am creating the database in MS Access. I am making a page for user registration. After the user sends the page for registration, the server should send one unique registration number to the user. I am doing this in Tomcat server using JSP. So if you can help me then please do so. I desperately need this.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.