473,320 Members | 2,112 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,320 software developers and data experts.

How to validate characters encoding in the textbox

Hello:

How can I validate the character encoding of the textbox in a form?
For instance, when the user fills out a form, I need to be sure that he is
typing in English (I mean uses Latin characters - not Russian, Hebrew etc.).
Do you know any JS code sample that I could use?

I would appreciate your help.

Thank you,

--
Peter Afonin
Jul 20 '05 #1
6 4190
DU
Peter wrote:
Hello:

How can I validate the character encoding of the textbox in a form?
For instance, when the user fills out a form, I need to be sure that he is
typing in English (I mean uses Latin characters - not Russian, Hebrew etc.).
Do you know any JS code sample that I could use?

I would appreciate your help.

Thank you,


http://www.w3.org/TR/html401/interac...accept-charset

DU
Jul 20 '05 #2
Thank you.

I think this applies only to the whole form, I need to apply this only to
the particular textboxes. I'll try though.

Peter

"DU" <dr*******@hotWIPETHISmail.com> wrote in message
news:bv**********@news.eusc.inter.net...
Peter wrote:
Hello:

How can I validate the character encoding of the textbox in a form?
For instance, when the user fills out a form, I need to be sure that he is typing in English (I mean uses Latin characters - not Russian, Hebrew etc.). Do you know any JS code sample that I could use?

I would appreciate your help.

Thank you,


http://www.w3.org/TR/html401/interac...accept-charset

DU

Jul 20 '05 #3
DU
Peter wrote:
Thank you.

I think this applies only to the whole form,
Yes it applies only to the whole form. The spec clearly mentions that
you can provide a comma-separated list of accepted charsets.

accept-charset %Charsets; #IMPLIED -- list of supported charsets --

"This attribute specifies the list of character encodings for input data
that is accepted by the server processing this form. The value is a
space- and/or comma-delimited list of charset values.(...)"
http://www.w3.org/TR/html401/interac...accept-charset

Browser support for this particular attribute with this unique feature
could be weak, partial, incomplete or buggy. I really don't know.

I need to apply this only to the particular textboxes. I'll try though.

Peter


http://www.w3.org/TR/html401/interac...accept-charset

DU


"A.3.13 Changes for internationalization

HTML 4.0 integrates the recommendations of [RFC2070] for the
internationalization of HTML.

However, this specification and [RFC2070] differ as follows:

* The accept-charset attribute has been specified for the FORM
element rather than the TEXTAREA and INPUT elements."
http://www.w3.org/TR/html401/appendi....html#h-A.3.13

DU
Jul 20 '05 #4
"Peter" <pv*@speakeasy.net> wrote in message news:<W3********************@speakeasy.net>...
Hello:

How can I validate the character encoding of the textbox in a form?
For instance, when the user fills out a form, I need to be sure that he is
typing in English (I mean uses Latin characters - not Russian, Hebrew etc.).
Do you know any JS code sample that I could use?

I would appreciate your help.

Thank you,


I can be mistaken, but I guess you can *not* do such validation.
You may want to look here:
http://ppewww.ph.gla.ac.uk/%7eflavel...form-i18n.html
--
Regards,
Paul Gorodyansky
"Cyrillic (Russian): instructions for Windows and Internet":
http://ourworld.compuserve.com/homepages/PaulGor/
Jul 20 '05 #5
What I said and what you wish I'd said,
may not be the same. Please quote the former.

"Peter" <pv*@speakeasy.net> wrote in message
news:W3********************@speakeasy.net...
Hello:

How can I validate the character encoding of the textbox in a form?
For instance, when the user fills out a form, I need to be sure that he is
typing in English (I mean uses Latin characters - not Russian, Hebrew etc.).
Do you know any JS code sample that I could use?

I would appreciate your help.

Thank you,

--
Peter Afonin


You could try something like below. For demonstration I have set it arbitrarily
to reject characters with a unicode > 196, although you would have to decide on
a range suitable for your needs.
For simplicity this algorithm checks only the last character typed. You may wish
to scan the entire text, either on a timed basis or when the field loses focus.

<html>
<body>
<FORM>
<input name="anglo" type=text size=40 onkeyup='latinCheck(this);'>
</FORM>

<SCRIPT>
function latinCheck(s)
{
if(s.value.length && s.value.charCodeAt(s.value.length-1) > 196)
{
s.value=s.value.substring(0,s.value.length-1);
alert('Illegal character typed');
}
}
</SCRIPT>

</body>
</html>

--
Stephen Chalmers


Jul 20 '05 #6
Thank you very much, Stephen. This works!

Peter

"Stephen Chalmers" <sp*********************@ntlworld.com> wrote in message
news:qG**********************@newsfep2-win.server.ntli.net...
What I said and what you wish I'd said,
may not be the same. Please quote the former.

"Peter" <pv*@speakeasy.net> wrote in message
news:W3********************@speakeasy.net...
Hello:

How can I validate the character encoding of the textbox in a form?
For instance, when the user fills out a form, I need to be sure that he is typing in English (I mean uses Latin characters - not Russian, Hebrew etc.). Do you know any JS code sample that I could use?

I would appreciate your help.

Thank you,

--
Peter Afonin

You could try something like below. For demonstration I have set it

arbitrarily to reject characters with a unicode > 196, although you would have to decide on a range suitable for your needs.
For simplicity this algorithm checks only the last character typed. You may wish to scan the entire text, either on a timed basis or when the field loses focus.
<html>
<body>
<FORM>
<input name="anglo" type=text size=40 onkeyup='latinCheck(this);'>
</FORM>

<SCRIPT>
function latinCheck(s)
{
if(s.value.length && s.value.charCodeAt(s.value.length-1) > 196)
{
s.value=s.value.substring(0,s.value.length-1);
alert('Illegal character typed');
}
}
</SCRIPT>

</body>
</html>

--
Stephen Chalmers



Jul 20 '05 #7

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

Similar topics

0
by: Jim M | last post by:
As shown below, I can use onKeyPress for the html text box control, but onKeyPress (client side) is not available to me using a web form text box to do my validation on the client side. So how do...
2
by: Nick | last post by:
In VS 2003 and VS 2005 beta 2 I am trying to write a simple program. It has a datagrid and a textbox along with a menubar. There is a command in the menu bar which is "Run Query" and has the...
2
by: Krzysiek | last post by:
Hello, in what code-page are characters stored in MSSQL tables? is it windows1250? -- Chris
2
by: anonieko | last post by:
This applies to javascript dynamic textbox onkey > > > Newsgroups: comp.lang.javascript From: Lasse Reichstein Nielsen <l...@hotpop.com> - Find messages by this author Date: Fri, 15 Jul 2005...
1
by: Reddy | last post by:
Hi, My web form has a dropdown list and a textbox server controls. The user must enter some text in the textbox he selects only the last item in the dropdownlist. I tried using a custom...
4
by: Peter Afonin | last post by:
Hello: How can I validate the character encoding of the textbox in ASP.Net form? For instance, when the user fills out a form, I need to be sure that he is typing in English (I mean uses Latin...
2
by: Ned | last post by:
I am trying to use a CustomValidator on a textbox. The Validator uses a client-side funtion but it doesn't run if the textbox is empty. If there is data in the text box it runs fine. Any...
1
by: Ian | last post by:
I have an ASP.NET 2.0 page with a readonly textbox on it who's value is populated by a popup child window used for selecting from a list. I use a javascript function to pass the data back to the...
10
by: Martin | last post by:
Hi all, When a user enters a german character in a textbox (such as ö ä ü ß) and I try to save it, these characters get converted to a different character. How can I prevent this? Tia,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.