Skip to content

Instantly share code, notes, and snippets.

@gbalbuena
Last active August 29, 2015 13:56
Show Gist options
  • Save gbalbuena/8960156 to your computer and use it in GitHub Desktop.
Save gbalbuena/8960156 to your computer and use it in GitHub Desktop.
This code defines a new vtype for Extjs 3 for the definition of a color value type
Ext.apply(Ext.form.VTypes, {
// Color vtype definition
color: function(v) {return /^#(?:[0-9a-f]{3}){1,2}$/i.test(v);},
colorText: 'This field must be a valid hex web color.',
colorMask: /[#0-9a-f]/i,
});
...
new Ext.form.TextField({
name: 'default_color',
fieldLabel : 'Default color',
xtype: 'textfield',
vtype: 'color'
}),
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment