View Full Version : Textfield default value

1 Dec 2007, 8:40 PM

I've been trying to get this to work for a while now, with no luck...
I have a FormPanel (in a Window) that'll popup on request...

My problem is; I want the 'Website' field to have a standard value of 'http://' that is visible when the form is created, and stay as a default value when the 'Website'-line is activated.
The user should only have to enter 'www.google.com' to get a validated 'http://www.google.com' URL ... and if they enter nothing, I'd like vtype to consider it a valid empty URL... (it seems to work that way at the moment, except that the 'http://'-part is removed on focus).

I've tried focus, blur, beforexxx etc...

The code I'm using (cut down to a bare minimum & displayed with a Ext.Window):

var contactForm = new Ext.FormPanel({
labelWidth: 75,
bodyStyle:'padding:5px 5px 0',
labelAlign: 'right',
defaults: {width: 250},
defaultType: 'textfield',
items: [{
fieldLabel: 'Website',
name: 'site',
vtype: 'url',
allowBlank: true,
emptyText: 'http://',
value: 'http://',
I've probably missed something basic, but... grateful for any help. :)

1 Dec 2007, 11:35 PM
Use your own validator function instead of vtype.

7 Jun 2014, 3:25 AM
remove emptyText:http:// it will work i had the same requireement i did it by not adding emptyText