views:

94

answers:

4

Hi, Does anybody know how the username input field of Twitter works? In the registration form, if you type any UTF-8 character it will not be rendered. How is that done?

+3  A: 

Javascript validation.

fiXedd
yeah, thats obvious right!?
Yes, fiXedd is right :) The code is here: https://s3.amazonaws.com/twitter_production/a/1253569923/javascripts/signup.js?1253571264
lost-theory
@George, then what are you asking?
fiXedd
A: 

Maybe one of the functions listed here, in conjunction with some other Javascript?

Donut
A: 

I use the following jQuery code for my site. It differs slightlty from Twitter as they allow underscores and I don't.

$(function(){ $('input[name="username"]').keydown(function(key){ if (jQuery.inArray(key.keyCode, [8,37,39,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90]) == -1 || key.shiftKey ){ return false; } }); });

knorthfield
Ok, that javascript looks horrible. Any tips on making it look nice?
knorthfield
A: 

$('.sample2').alphanumeric({allow:"., "});

this code only allow to type alpha numeric and alow some special characters

sample2 this is your text field class

i hope this will help you

gowri