Results 1 to 7 of 7

Thread: Allow text field to validate when empty

  1. #1

    Default Allow text field to validate when empty

    I have two text fields. The first field (email) requires text, the 2nd field (label)
    is optional. I am using a formBind for the button and monitorValid for the
    form. The form is requiring some text to be entered for the label field,
    although it is optional. How do I allow an empty field to be validated OK?

    The code is below.

    var emailField = new Ext.form.TextField({
              inputType: 'text',
              fieldLabel: 'Email addresses',
              emptyText: 'Enter one or more email addresses,separated by a comma',
              name: 'email',
              vtype: 'multiemail'
     var labelField = new Ext.form.TextField({
              inputType: 'text',
              allowBlank: true,
              fieldLabel: 'Label (optional)',
              name: 'label',
       // Panels             
       //Top form panel
       var fp = new Ext.FormPanel({
            region: 'north',
            width: 300,
            frame: true,
            title: 'Register Form',
            autoHeight: true,
            bodyStyle: 'padding: 10px 10px 0 10px;',
            labelWidth: 100,
            defaults: {
                anchor: '95%',
                allowBlank: false,
                msgTarget: 'side'
            monitorValid: true,
            items: [ {
                      id: 'registerInfoPanel',
                  background: '#ffffff',
                  padding: '7px'
                        html: 'To register 1 or bom files, <br>' +
                              '- Enter the email addresses to be notified when registration is done<br>'+ 
                              '- Enter an optional label to be associated with the release<br>' +
                              '- Press the Upload Bom Files button<br>' +
                              '- Select one or more bom files<br>' +
                              '- Press the Upload button to begin the registation process<br><br>' +
                              'After uploading is complete, a job id will be assigned'
            emailField,labelField ],
            buttons: [{
               text: 'Upload Bom File(s)',
               handler: function () {
    Thanks in advance,
    Don McClean

  2. #2
    Sencha User
    Join Date
    Mar 2007


    Yep. I hit this, and reported it.

    It's a simple fix, but they don't want to change it. You'll have to run with an override.

    I have a huge ExtOverrides.js file in my app...

  3. #3


    Animal, thanks for the quick response.

    I probably did not state what I needed very well. If the optional field is empty, I
    consider the field valid, and do not need to run any other validator. I am attempting to
    get this effect by setting the allowBlank to be true, but the form button
    is not enabled until I enter at least one character, even if it is blank.

    Ps, I did use your override, but it did not alter this particular behavior.

    Don McClean

  4. #4
    Ext User
    Join Date
    Jul 2007



    1. instead of new Ext.form.TextField use an xtype, or
    2. do not use the defaults option to set allowBlank.

    Rationale for this response is presented here:

  5. #5


    Thanks, that fixed it!


  6. #6


    Guys, first, thanks for this solution, it seems useful for what i'm doing (which is pretty much what dmcclean needed too), but I have one question, is this valid for "empty" fields? meaning this, fields filled just with spaces? as the default empty text validation doesn't seem to consider blank spaces as empty text... Any help would be much appreciated


  7. #7


    feeling the need to have an optional format (including email) field, I created one of my own:

    I am aware that this is an ExtJS2 thread is unsupported.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts