title: Can Dynamic Vtype validation Done(like below code) in extjs
body: <p>I am new to extjs. I like to know,  Is it possible to do dynamic vtype validation like below code...</p>
  
  <pre><code>customRegEX = /^[a-z0-9]/i
  
  customMsg = 'Must be an alphanumeric word'
  
  
  function ConstructVtype(customRegEX,customMsg)
  {
      var custExp = customRegEX;
      Ext.apply(Ext.form.VTypes, {
          AlphaNum: function(v,field) {   
              return /^[a-z0-9]/i.test(v); // instead of this code
              return custExp.test(v);
          },
          AlphaNumText: customMsg,
          AlphaNumMask: custExp
      });
  }
  </code></pre>
  
  <p>But I am getting error (Object does not support this method) in the line <code>return custExp.test(v);</code>
  since there is no method called test in the object(<code>custExp</code>)</p>
  
  <p>Is it possible to typecast <code>custExp</code> to that object which hold the test method,</p>
  
  <p>If the above point is possible means pls provide that object type and how to typecast ?
                                  OR
  Provide how can I achieve this functionality in different way.</p>
  
  <p>hi "Alexander Gyoshev"  thanks for ur replay </p>
  
  <p>if i do as per u recommended its working man but i need to change the regexp value dynamically by the textfield change, like the below code how can do this man</p>
  
  <pre><code>function ConstructVtype()
  {   
      var customRegEX = this.customRegEX;  ////^[a-z0-9]/i,
      customMsg =this.customErrorMsg;
  
      Ext.apply(Ext.form.VTypes, {
          AlphaNum: function(v,field) {
              return customRegEX.test(v);
          },
          AlphaNumText: customMsg,
          AlphaNumMask: customRegEX
      }); 
  
  }
  
  
  var txt = new Ext.form.TextField({
   renderTo:Ext.getBody(),
    validator :ConstructVtype,
    fieldLabel: 'Telephone',
    name: 'Telephone',
    vtype:'AlphaNum',
    id:'test1',
    customRegEX:'/^[a-z0-9]/i',
    customErrorMsg:'Must be an alphanumeric word',
    width:240  
  
  });
  
  var txt2 = new Ext.form.TextField({
   renderTo:Ext.getBody(),
    validator :ConstructVtype,
    fieldLabel: 'Telephone',
    name: 'Telephone',
    vtype:'AlphaNum',
    id:'test2',
    customRegEX:'/^[a-zA-Z]/i',
    customErrorMsg:'Must be an alphabets',
    width:240  
  
  });
  </code></pre>
  
  <p>Thanks in advance</p>