How to validate characters encoding in the textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter

    #1

    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


  • DU

    #2
    Re: How to validate characters encoding in the textbox

    Peter wrote:
    [color=blue]
    > 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,
    >[/color]

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

    DU

    Comment

    • Peter

      #3
      Re: How to validate characters encoding in the textbox

      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" <drunclear@hotW IPETHISmail.com > wrote in message
      news:bvk8u4$kia $1@news.eusc.in ter.net...[color=blue]
      > Peter wrote:
      >[color=green]
      > > 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[/color][/color]
      is[color=blue][color=green]
      > > typing in English (I mean uses Latin characters - not Russian, Hebrew[/color][/color]
      etc.).[color=blue][color=green]
      > > Do you know any JS code sample that I could use?
      > >
      > > I would appreciate your help.
      > >
      > > Thank you,
      > >[/color]
      >
      > http://www.w3.org/TR/html401/interac...accept-charset
      >
      > DU[/color]


      Comment

      • DU

        #4
        Re: How to validate characters encoding in the textbox

        Peter wrote:
        [color=blue]
        > Thank you.
        >
        > I think this applies only to the whole form,[/color]

        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[color=blue]
        > the particular textboxes. I'll try though.
        >
        > Peter
        >
        >[color=green]
        >>
        >>http://www.w3.org/TR/html401/interac...accept-charset
        >>
        >>DU[/color]
        >
        >
        >[/color]


        "A.3.13 Changes for internationaliz ation

        HTML 4.0 integrates the recommendations of [RFC2070] for the
        internationaliz ation 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

        Comment

        • Paul Gorodyansky

          #5
          Re: How to validate characters encoding in the textbox

          "Peter" <pva@speakeasy. net> wrote in message news:<W3SdnV5EQ rpIoYDdXTWc-g@speakeasy.net >...[color=blue]
          > 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,[/color]

          I can be mistaken, but I guess you can *not* do such validation.
          You may want to look here:



          --
          Regards,
          Paul Gorodyansky
          "Cyrillic (Russian): instructions for Windows and Internet":

          Comment

          • Stephen Chalmers

            #6
            Re: How to validate characters encoding in the textbox

            What I said and what you wish I'd said,
            may not be the same. Please quote the former.

            "Peter" <pva@speakeasy. net> wrote in message
            news:W3SdnV5EQr pIoYDdXTWc-g@speakeasy.net ...[color=blue]
            > 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
            >[/color]

            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='latinC heck(this);'>
            </FORM>

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

            </body>
            </html>

            --
            Stephen Chalmers








            Comment

            • Peter Afonin

              #7
              Re: How to validate characters encoding in the textbox

              Thank you very much, Stephen. This works!

              Peter

              "Stephen Chalmers" <spamTheMothers ToBuggery@ntlwo rld.com> wrote in message
              news:qGQTb.4503 1$OA3.14231790@ newsfep2-win.server.ntli .net...[color=blue]
              > What I said and what you wish I'd said,
              > may not be the same. Please quote the former.
              >
              > "Peter" <pva@speakeasy. net> wrote in message
              > news:W3SdnV5EQr pIoYDdXTWc-g@speakeasy.net ...[color=green]
              > > 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[/color][/color]
              is[color=blue][color=green]
              > > typing in English (I mean uses Latin characters - not Russian, Hebrew[/color][/color]
              etc.).[color=blue][color=green]
              > > Do you know any JS code sample that I could use?
              > >
              > > I would appreciate your help.
              > >
              > > Thank you,
              > >
              > > --
              > > Peter Afonin
              > >[/color]
              >
              > You could try something like below. For demonstration I have set it[/color]
              arbitrarily[color=blue]
              > to reject characters with a unicode > 196, although you would have to[/color]
              decide on[color=blue]
              > a range suitable for your needs.
              > For simplicity this algorithm checks only the last character typed. You[/color]
              may wish[color=blue]
              > to scan the entire text, either on a timed basis or when the field loses[/color]
              focus.[color=blue]
              >
              > <html>
              > <body>
              > <FORM>
              > <input name="anglo" type=text size=40 onkeyup='latinC heck(this);'>
              > </FORM>
              >
              > <SCRIPT>
              > function latinCheck(s)
              > {
              > if(s.value.leng th && s.value.charCod eAt(s.value.len gth-1) > 196)
              > {
              > s.value=s.value .substring(0,s. value.length-1);
              > alert('Illegal character typed');
              > }
              > }
              > </SCRIPT>
              >
              > </body>
              > </html>
              >
              > --
              > Stephen Chalmers
              >
              >
              >
              >
              >
              >
              >
              >[/color]


              Comment

              Working...