473,473 Members | 4,208 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Grab the text from a textbox

Guys,

I need to know what kind of characters is being used in a textbox,
whether Latin or Unicode. Depending on that I want to make a countdown.

For example:

if the characters are Latin, i want the countdown to start with 200
if it contained a unicode character, then it will start with 100.

Any ideas?

Oct 26 '05 #1
2 1304
te******@gmail.com wrote:
Guys,

I need to know what kind of characters is being used in a textbox,
whether Latin or Unicode. Depending on that I want to make a countdown.

For example:

if the characters are Latin, i want the countdown to start with 200
if it contained a unicode character, then it will start with 100.

Any ideas?


What do you mean by "unicode characters"? All Latin-alphabet characters
are also part of Unicode. Furthermore, "Latin" might mean different
things to different people.

If you want to scan the string for any characters outside the normal
ASCII range, you can just loop through and test the code of each
character:

function containsNonASCII(s) {
for (var pos in s) {
var c = s.charCodeAt(pos)
if (c < 0x20 || c > 0x7f) return true;
}
return false;
}

Note that this will exclude accented characters as well. If you want to
count those as Latin, you'll need to modify the function to allow
whichever specific subranges -- that's left as an exercise to the
reader.

-- David

Oct 26 '05 #2
David Wahler wrote:
function containsNonASCII(s) {
for (var pos in s) {
Won't work with a strict ECMAScript implementation and not with MS JScript
(at least not with all versions) since String objects do not have numbered
properties for each character of the string value there.

for (var pos = s.length; pos--;)
{

will always work.
var c = s.charCodeAt(pos)
if (c < 0x20 || c > 0x7f) return true;
}
return false;
}


/[^\x20-\x7F]/.test(s)

will work in JavaScript from version 1.3 (NN4), ECMAScript version < 3
and compatibles but will maybe exclude Unicode characters.

/[^\u0020-\u007F]/.test(s)

will work in ECMAScript 3+ and compatibles and should include all Unicode
characters.

BTW, the range [\x00-\x1A] does contain ASCII characters with, just not
printable ones, i.e. the function identifier does not reflect its purpose.
PointedEars
Oct 26 '05 #3

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

Similar topics

3
by: dan glenn | last post by:
hi. I want to code a 'preview' function into a guestbook entry page. I can do it with a button that posts, bringing up a whole new page showing a preview of what has been entered, and then the user...
0
by: Baby Blue | last post by:
I have 2 code like below to grab a news website for my site. However, when I click some links (such as : http://wwww.vnexpress.net/xxx/xxxx ) inside the site which I want to grab, it has some...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
6
by: Lance Geeck | last post by:
I have a simple form where I am using a dataset called Client. On the data entry screen, there are name, address, city state and zip. I have the fields bound to the dataset field. (Properties...
2
by: brad | last post by:
I need to know how to grab text from and enter text into another running programs textboxes. I dont know where to begin to look.
4
by: Eric Layman | last post by:
HI, Im on dotnet 1.1 I've generated extra checkboxes, textboxes via client side javascript: eg: var inputElement = document.createElement('input'); inputElement.setAttribute('type',...
16
by: mj.redfox.mj | last post by:
Can anyone help? I have a textbox which I'm programatically adding by using the following code: txtTest = New TextBox txtTest.ID = "txtLeft" + cntCount.ToString...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.