allowed: '0123456789',
+ max_length: 15,
+
/**
* @cfg {String} defaultDialCode The default dial code when initializing the input
*/
var input = {
tag: 'input',
id : id,
+ type: 'number',
+ maxlength: this.max_length,
cls : 'form-control tel-input',
autocomplete: 'new-password'
};
this.list.on('mouseover', this.onViewOver, this);
this.list.on('mousemove', this.onViewMove, this);
- this.inputEl().on("keypress", this.onKeyPress, this);
+ this.inputEl().on("keyup", this.onKeyUp, this);
this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
cls: 'typeahead typeahead-long dropdown-menu tel-list',
style: 'display:none'
});
- this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
+
+ this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
},
collapseIf : function(e)
this.validate();
},
- getDialCode : function(v = '')
+ getDialCode : function(v)
{
+ v = v || '';
+
if (v.length == 0) {
return this.dialCodeHolder.dom.value;
}
return this.el.select('input.hidden-tel-input',true).first();
},
- onKeyPress : function(e){
+ onKeyUp : function(e){
var k = e.getKey();
var c = e.getCharCode();
if(
- (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
+ [",", "."].indexOf(String.fromCharCode(c)) > -1 ||
this.allowed.indexOf(String.fromCharCode(c)) === -1
){
-
- Roo.log('stoping event???');
e.stopEvent();
- return;
}
- /*
- if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
- return;
- }
+ // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
+ // return;
+ // }
if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
e.stopEvent();
}
- */
this.setValue(this.getValue());
}