Search code examples
extjs3

Charcter Validation In Ext js3.4


I want to check validation for textfield in Ext js3.4...Validation condition is first 5 Character must be "ROLE_"...How would I check them...I also trying for getting value on keypress event through getKey method ..But I got only ASCII value ..how would I convert them.


Solution

  • Have you tried keydown keyup events in listeners, in those events you will directly get the value using the id of the text field... here you go for a sample code

    xtype:'textfield'
    fieldLabel: 'First Name',
    name: 'first',
    allowBlank:false,
    id:'name',
    listeners:
     keyup:function(this,e){
    var desiredname= Ext.getCmp('name').value;
    if(desiredname.length==5)
    {
                 //YOUR CODE :)
    }
    
    }
    

    Hope this helps you...