Check Validation - InfoPath Dev
in

InfoPath Dev

Check Validation

Last post 08-14-2006 09:14 PM by liorlankri. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 08-14-2006 12:58 AM

    Check Validation

    I have a Text Box in my form.
    How can I check that the input is English letters (and not Hebrew for example)??
  • 08-14-2006 08:41 AM In reply to

    Wow this is a very interesting question and the first time I believe it has ever been asked, ever.

    I believe the only way you could do this would be to add code in the onValidate handler to validate the input manually. Maybe someone else could explain the type of code involved.
    Shiraz Cupala / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 08-14-2006 09:20 AM In reply to

    This is an interesting question. The best way I can think of to test for this kind of question is to check the default encoding of the .NET 2.0 framework installed on the computer. I have provided a link to the documentation below, but here is a quick outline of what I think might work. Please note that I have not tested this code.

    System.Text.Encoding default = System.Text.Encoding.Default;

    int codePage = default.CodePage;

    if( codePage == 437 )
    {
    // 437 IBM437 OEM United States
    }
    else
    {
    // Something else
    }



    http://msdn2.microsoft.com/en-us/library/system.text.encoding.aspx

    http://msdn2.microsoft.com/en-us/library/system.text.encoding.codepage.aspx

    You'll have to play around with exactly which code pages you want to check for and how you want to handle each, but I think this should get you headed in the right direction.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 08-14-2006 09:21 AM In reply to

    Text is stored in the XML in ASCII characters. There's no encoding specified. English characters are all going to have ASCII values between of 32-127. Anything above that would be either a special character or a foreign language character. A quick internet search revealed that Hebrew fonts map to ASCII 224-250.

    The other issue you run into is that other languages, Japanese for example, will store two ASCII characters in the XML to represent a single foreign character when displaying.

    In general, if you have a whole string of characters that are all lower ASCII values, then its likely to be English.
  • 08-14-2006 02:35 PM In reply to

    XML is stored in UTF-8 or UTF-16. The InfoPath default is UTF-8. UTF stands for Unicode Text Format. The difference between UTF-8 and UTF-16 is the default character length. In UTF-8, it's multi-byte; in UTF-16, all characters are two bytes, i.e. 16 bits.

    Saying it's ASCII doesn't mean much. It's ANSI for Codepage 0, which is what English uses for most of it's characters. Japanese and other languages will use 2 bytes for characters and neither will be ASCII. The high-byte will typically be in a given range (with high bit set) to indicate that it's two bytes (vs. 1)
    Patrick Halstead
    Project Manager at Qdabra
  • 08-14-2006 09:14 PM In reply to

    I need this code in VBscript
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.