Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1051541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:57:01+00:00 2026-05-16T16:57:01+00:00

In Javascript, is there a way (that survives internationalization) to determine whether a character

  • 0

In Javascript, is there a way (that survives internationalization) to determine whether a character is a letter or digit? That will correctly identify Ä, ç as letters, and non-English digits (which I am not going to look up as examples)!

In Java, the Character class has some static methods .isLetter(), .isDigit(), .isLetterOrDigit(), for determining in an internationally suitable way that a char is actually a letter or digit. This is better than code like

//this is not right, but common and easy
if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')) { //it's a letter

because it will pick up non-English letters. I think C# has similar capabilities…

Of course, at worst I can send strings back to the server to be checked but that’s a pain…

Of course, in the end I am looking to check if input is a valid name (starts with a letter, the rest is letter or digit). An outside the box possibility for low volume use might be:

var validName=function(atr) {
    var ele=document.createElement("div");
    try { ele.setAttribute(atr,"xxx"); }
    catch(e) { return false; }
    return true;
    }

This tests out fairly decent in IE, FF and Chrome… Though thorough testing might be needed to figure out how consistent the answers are. And again, not appropriate for heavy duty usage due to element creation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:57:01+00:00Added an answer on May 16, 2026 at 4:57 pm

    I have created a small Javascript utility to provide this functionality. I don’t claim it is perfect, so let me know how you fair. If people like it, I’ll make this the official answer to this question.

    CharFunk: https://github.com/joelarson4/CharFunk

    • CharFunk.getDirectionality(ch) – Used to find the directionality of the character
    • CharFunk.isAllLettersOrDigits(string) – Returns true if the string argument is composed of all letters and digits
    • CharFunk.isDigit(ch) – Returns true if provided a length 1 string that is a digit
    • CharFunk.isLetter(ch) – Returns true if provided a length 1 string that is a letter
    • CharFunk.isLetterNumber(ch) – Returns true if provided a length 1 string that is in the Unicode “Nl” category
    • CharFunk.isLetterOrDigit(ch) – Returns true if provided a length 1 string that is a letter or a digit
    • CharFunk.isLowerCase(ch) – Returns true if provided a length 1 string that is lowercase
    • CharFunk.isMirrored(ch) – Returns true if provided a length 1 string that is a mirrored character
    • CharFunk.isUpperCase(ch) – Returns true if provided a length 1 string that is uppercase
    • CharFunk.isValidFirstForName(ch) – Returns true if provided a length 1 string that is a valid leading character for a JavaScript identifier
    • CharFunk.isValidMidForName(ch) – Returns true if provided a length 1 string that is a valid non-leading character for a ECMAScript identifier
    • CharFunk.isValidName(string,checkReserved) – Returns true if the string is a valid ECMAScript identifier
    • CharFunk.isWhitespace(ch) – Returns true if provided a length 1 string that is a whitespace character
    • CharFunk.indexOf(string,callback) – Returns first matching index that returns a true return from the callback
    • CharFunk.lastIndexOf(string,callback) – Returns last matching index that returns a true return from the callback
    • CharFunk.matchesAll(string,callback) – Returns true if all characters in the provided string result in a true return from the callback
    • CharFunk.replaceMatches(string,callback,ch) – Returns a new string with all matched characters replaced
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way (preferrably using JavaScript) to determine whether a URL is to
Is there a way to spawn a new window via javascript in IE7 that
Is there a way that a JavaScript function can read the JavaScript source code
Is there any way that I can call a JavaScript function via css? For
Is there a way that you can pass in a javascript object to a
IS there any way that I can read config values in web.config with javascript
is there a way that I could automatically format the input box via Javascript
The Question: Is there a way that I can pass a JavaScript function into
Is there any way in JavaScript to create a "weak reference" to another object?
Is there a way to debug javascript using Safari 3.2 in Windows Vista? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.