473,396 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

change variable in javascript

i use the following script (from textbook) to restrict 160 character in
Message_cont textbox.

how can i to change the number of character to 70 if any double bytes
character detected in the textbox. Thanks a lot.

tony

*********************************
var text1;
function checklength()
{
var txt;
txt=document.formsend.Message_cont.value;
n=txt.length;
if (n>160)
{
document.formsend.Message_cont.value=text1;
return;
}
text1=document.formsend.Message_cont.value;
}

*************detect double byte character****************
( /[\u0100-\uffff]/.test( document.formsend.Message_cont.value ) )
Oct 22 '06 #1
2 1847
tony wong wrote on 22 okt 2006 in comp.lang.javascript:
i use the following script (from textbook) to restrict 160 character
in Message_cont textbox.

how can i to change the number of character to 70 if any double bytes
character detected in the textbox. Thanks a lot.

var text1 = 'My text';

function checklength() {

var cont = document.forms['formsend'].elements['Message_cont'];
var dblB = /[\u0100-\uffff]/.test( cont.value );
var max = ( dblB ) ? 160 : 70;

if ( cont.value.length max )
cont.value = text1
else
text1 = cont.value;

};

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 22 '06 #2
Thanks a lot. Evertjan
"Evertjan." <ex**************@interxnl.net¼¶¼g©ó¶l¥ó·s»D:Xn*** *****************@194.109.133.242...
tony wong wrote on 22 okt 2006 in comp.lang.javascript:
>i use the following script (from textbook) to restrict 160 character
in Message_cont textbox.

how can i to change the number of character to 70 if any double bytes
character detected in the textbox. Thanks a lot.


var text1 = 'My text';

function checklength() {

var cont = document.forms['formsend'].elements['Message_cont'];
var dblB = /[\u0100-\uffff]/.test( cont.value );
var max = ( dblB ) ? 160 : 70;

if ( cont.value.length max )
cont.value = text1
else
text1 = cont.value;

};

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Oct 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: TheKeith | last post by:
I don't know much about javascript, so take it easy on me. Is there a way to dynamically change a CSS layers dimensions on the fly. Here is what I'm doing. I have a bunch of thumbnails that when...
2
by: Irvin Amoraal | last post by:
I am new to javascript coding. I am using some javascript code to change an image on an html page. I would like the user to click on the image to bring them to another page. I need to change an...
9
by: Nick | last post by:
I have the following code, and it works well on Mozilla 1.6. (However, the image src property cannot be set on Mozilla 1.2.1). Unfortunately, all the code: document.images.itemImage.src =...
1
by: kuba | last post by:
hello i've problem. here is sample code: <SCRIPT LANGUAGE="JavaScript"> <!-- //var city = NewYork;
3
by: Rob | last post by:
Hi all, Javascript is not my strong point but I have a little problem with a function. I have ASP code that displays form variables for x number of users. Depending on the radio button they...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
3
by: Byron | last post by:
Hi, Javascript confuses me, so I usually limit myself to Dreamweaver's built-in scripts for stuff like imageswaps. But this time I'm trying to write something very simple myself. I do most of my...
7
by: dotnetnoob | last post by:
i keep getting Object references not set to an instance of an object from this code: Private Sub EqBinding() Dim x As Integer x = 0 Do If CStr(arlsType.Item(x)) = "Bacnet Point" Then Dim...
4
by: vfpuglia | last post by:
Hi, Lets get it out there... I'm a newbie to javascript. I'm trying to build a string for the external source file destination and be able to change the keywords in the string based on what...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.