View:
<Label text="Name"/>
<Input Id="NameId" text="" liveChange="validateName"/>
Controller.js
validateName:function(oEvent){
var text = oEvent.getSource().getValue();
var reg = /^[a-zA-Z]+$/;
if( !text.match(reg) ){
if( !isNaN( text.charAt(0)) || !text.charAt(0).match(reg)){
text = text.substring( 1 , text.length );
}else if( !isNaN( text.charAt( text.length - 1 )) || !text.charAt(text.length - 1).match(reg)){
text = text.substring( 0 , text.length - 1 );
}else{
for( var i = 0 ; i < text.length; i++ ){
if( !isNaN( text.charAt(i) ) || !text.charAt(i).match(reg)){
text = text.split( text.charAt(i) )[0] + text.split( text.charAt(i) )[1];
}
}
}
oEvent.getSource().setValue( text );
}else{
oEvent.getSource().setValueState( "None" );
}
},