Code:
items: new Ext.ux.PasswordField({
showCapsWarning: true,
maskRe: /[^A-Z]/,
dataIndex: 'senha_funcionario',
fieldLabel: 'Senha',
name: 'senha_funcionario',
id : 'senha_funcionario',
type: 'string',
anchor:'95%'
}),
},{
columnWidth:.3,
layout: 'form',
items: new Ext.ux.PasswordField({
showCapsWarning: true,
maskRe: /[^A-Z]/,
fieldLabel: 'Repetir Senha',
name: 'repetir_senha_funcionario',
id : 'repetir_senha_funcionario',
type: 'string',
anchor:'95%'
}),
},{
Code:
Ext.extend(Ext.ux.PasswordField, Ext.form.TextField, {
/**
* @cfg {String} inputType The type attribute for input fields -- e.g. text, password (defaults to "password").
*/
inputType: 'password',
// private
onRender: function(ct, position) {
Ext.ux.PasswordField.superclass.onRender.call(this, ct, position);
// create caps lock warning box
var id = Ext.id();
this.alertBox = Ext.DomHelper.append(document.body,{
tag: 'div',
style: 'width: 10em; z-index: 10000',
children: [{
tag: 'div',
style: 'text-align: center; color: red;',
html: 'CAPSLOCK ATIVADO',
id: id
}]
}, true);
Ext.fly(id).boxWrap();
this.alertBox.hide();
this.on('beforedestroy', function(){
this.alertBox.hide()
});
},
initEvents: function() {
Ext.ux.PasswordField.superclass.initEvents.call(this);
this.el.on('keypress', this.keypress, this);
},
keypress: function(e) {
var charCode = e.getCharCode();
if(charCode >= 65 && charCode <= 90){
if (this.showCapsWarning) {
this.showWarning(e.target);
}
e.stopEvent();
if(Ext.isIE) {e.browserEvent.keyCode = 0;}
} else {
this.hideWarning();
}
},
blur: function(){
this.hideWarning();
},
showWarning: function(el) {
this.alertBox.alignTo(el, 'l-r', [5, 0]);
this.alertBox.show();
},
hideWarning: function() {
this.alertBox.hide();
}
}
);