PDA

View Full Version : Mask Input Plugin for TextField - Cross Browser



fother
22 Jan 2008, 4:25 AM
Credits for:
Softfocus Sistemas: www.softfocus.com.br
Demo: http://www.ricardosantos.com.br/extjs/example-form.php - Ext 1.0

I caught him the script and modified for use with 2.0 ext

work fine in ie, firefox, opera..
Someone can test with the safari?

ext-extend.js
[CODE]
Ext.namespace("Ext.ux","Ext.ux.form");

Ext.QuickTips.init();

// Extends Javascript Functions

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };

//
// form extends
//
Ext.ux.colfield = function(form, type, label, name, width, objconffield, objconf )

{
var config = {
width: width
};

Ext.apply( config, objconf );

var newField = Ext.ux.retfield( type, label, name, objconffield )
return newField;
}

Ext.ux.retfield = function( type, label, name, width, objconf )
{
var newField = {}, config = {
fieldLabel: label,
name: name,
width: width,
preventScrollbars: true,
cls: '',
allowBlank: true
};

Ext.apply( config, objconf );

if( config.width == undefined || config.width == 0 ) delete config.width;

switch( type )
{
case 'e':
config.vtype = 'email';
case 't':
case 'text':
var newField = new Ext.form.TextField( config );
break;
case 'tn':
case 'textnome':
var newField = new Ext.form.TextField( config );
newField.on('change', function( field, str ) { field.setValue(Ext.ux.form.masknome(str)); });
break;
case 'tel':
config.maskRe = /[0-9]/;
config.mask = '(##) ####-####';
config.minLength = 9;
config.valueDefault = '(13';
var newField = new Ext.form.TextField( config );

Ext.ux.form.Masking( newField );
break;

case 'cpfcnpj':
config.maskRe = /[0-9]/;
config.mask = config.mask1 = '###.###.###-##';
config.mask2 = '##.###.###/####-##';
config.minLength = 14;
var newField = new Ext.form.TextField( config );

Ext.ux.form.Masking( newField );
newField.on('valid', function( field ) {
var v = field.getValue(), n = v.replace( /[^0-9]/g, '' );
if( n.length == 11 && !Ext.ux.form.chkcpf(n)) field.markInvalid('O CPF est

dearsina
23 Jan 2008, 2:38 AM
Do you have an example running?

tof
23 Jan 2008, 3:25 AM
Do you have an example running?
Yes, on the given link (with ext 1.0).

Good work !

galdaka
23 Jan 2008, 1:36 PM
This forum in for Ext 2.0 extensions and plugins.

DragonFist
23 Jan 2008, 4:21 PM
This forum in for Ext 2.0 extensions and plugins.


--------------------------------------------------------------------------------

Credits for:
Softfocus Sistemas: www.softfocus.com.br
Demo: http://www.ricardosantos.com.br/extjs/example-form.php - Ext 1.0

I caught him the script and modified for use with 2.0 ext


Really need to read everything before reprimanding someone.

galdaka
25 Jan 2008, 2:30 PM
Really need to read everything before repremanding someone.

Sorry. My English is bad and I don

e_gama
29 Jan 2008, 4:27 AM
I need to modify the source to work correcty...

original line 21:
var newField = Ext.ux.retfield( type, label, name, objconffield )Modified line 21:
var newField = Ext.ux.retfield( type, label, name, width, objconffield )

Thanks for this perfect plugin.

fother
29 Jan 2008, 9:35 AM
in the next time will be possible use
xtype: 'inputMask',
mask: '###-##-##'

thanks for your suggestion :D
are be appreciate

dewie
31 Jan 2008, 10:56 AM
There are some problems in safari :

http://www.itxl.nl/safari_form.png

fother
2 Feb 2008, 8:49 AM
you can test with ext 2.x?

pludikhu
5 Mar 2008, 12:22 AM
There are some problems in safari :


I think this has nothing to do with Safari.

Probably mister Santos is experimenting (?) with compressed js files (ext-complete.js.gz) and it doesn't seem browsers like that, neither Firefox nor IE 7.

Rgds
Patrick

lombras
29 Oct 2008, 2:37 PM
Ae Ricardo, blz?

Muito legal essa parada que vc fez...

S

olimpia
5 Jun 2009, 12:16 PM
The address http://www.ricardosantos.com.br/extjs/example-form.php not this more accessible one.
Does anybody have the files to send me?