Twitter Name Validation

I believe it's letters, numbers and underscores only, and a maximum of 15 characters.

A quick search unveiled this post (non-Twitter) covering the same topic:

http://kagan.mactane.org/blog/2009/09/22/what-characters-are-allowed-in-twitter-usernames/

The above post also contains regex examples to help you validate:

Full regex – /^[a-zA-Z0-9_]{1,15}$/
Perl-compatible regex – /^\w{1,15}$/

Check this page from Twitter for the official guidelines/rules

http://support.twitter.com/articles/101299-why-can-t-i-register-certain-usernames#


This is the final JavaScript Funcion:

function validTwitteUser(sn) {
    return /^[a-zA-Z0-9_]{1,15}$/.test(sn);
}

Tags:

Regex

Twitter