In our registration form we now want to ask the user to enter their twitter name (eg @paul).
Can anyone tell what characters are allowed in it?
e.g. a-z, A-Z, underscores, 0-9
anything else?
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}$/
This is the final JavaScript Funcion:
function validTwitteUser(sn) {
return /^[a-zA-Z0-9_]{1,15}$/.test(sn);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With