0

I am using extjs version 3.1.0.

I create one simple code, which show alert message, if length of text entered is 12. suppose i entered (123456123456), then it is showing alert message i.e(Test) 3 times. My complete code is

Ext.onReady(function() {
    Ext.QuickTips.init();
     var searchForm = new Ext.form.FormPanel({
     id: "searchForm",
     renderTo: Ext.getBody(),
     items: [ {
          id: "itemUpc",
          fieldLabel: 'UPC',
          xtype: 'numberfield',
          labelStyle: 'font-size: x-large',
          height: '35px',
          name: 'itemUpc',
          validateValue : function(value){
             if(value.length ==12){
           alert("Test");
        return false;
        }  
        return false;
       }
         }]
    });
});

Please help me.

1 Answers1

0

if you want to restrict length, use minLength and maxLength properties

Ext.onReady(function() {
    Ext.QuickTips.init();
     var searchForm = new Ext.form.FormPanel({
     id: "searchForm",
     renderTo: Ext.getBody(),
     items: [ {
          id: "itemUpc",
          fieldLabel: 'UPC',
          xtype: 'numberfield',
          labelStyle: 'font-size: x-large',
          height: '35px',
          name: 'itemUpc',
          maxLength : 12,
          minLength : 12
         } ]
    });
});
ncank
  • 946
  • 5
  • 15
  • Thanks for response. on basis length == 12, I want to perform some action. Suppose user entered 12 digit that time it need to perform some action. Alert message is just for sample to check it will perform that action properly. – user1168826 Jul 12 '12 at 04:42
  • i see, you can also use keyup/keypress events to check length. validation may be triggered more than once, so keyup/keypress will solve your problem – ncank Jul 12 '12 at 14:57