Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created October 15, 2011 06:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronksaunders/1289182 to your computer and use it in GitHub Desktop.
Save aaronksaunders/1289182 to your computer and use it in GitHub Desktop.
Text field validator only alpha
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
win1.open();
var alphaonly = Titanium.UI.createTextField({
color:'#336699',
height:35,
width:300,
top:10,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
keyboardToolbarColor: '#999',
keyboardToolbarHeight: 40,
});
win1.add(alphaonly);
alphaonly.addEventListener('change', function(e){
var invalidChars = /[0-9]/gi
if(invalidChars.test(e.source.value)) {
e.source.value = e.source.value.replace(invalidChars,"");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment