Since there is no keypress event in titanium, I thought I would share this hack I used to make sure that a credit card number had a space between each 4 numbers as it was being typed.
You can re-work this general concept to use for various validation and formatting as the user is typing.
var textField = Ti.UI.createTextField(); var myInterval = false; function formatCC() { var str = textField.value.replace(/[^\d]/g,''); var i = 0; var newStr = ''; while( str[i] !== undefined ) { newStr += ''+str[i]; if ( (i+1) % 4 == 0 ) { newStr += ' '; } i++; } textField.value = newStr; } textField.addEventListener('focus', function(e) { myInterval = setInterval(function() { formatCC() },250); }); textField.addEventListener('blur', function(e) { clearInterval(myInterval); });Hope this helps someone!