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
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