1. #1
    Sencha User aityahia's Avatar
    Join Date
    Feb 2009
    Posts
    82
    Vote Rating
    0
    aityahia is on a distinguished road

      0  

    Default [Sloved][custom Vtype] form is valid if my field is invalid

    [Sloved][custom Vtype] form is valid if my field is invalid


    hi all
    i have writen an custom Vtype that check if an id already exist,the field is properly marked invalid if it is, but my form still validand can be submited.

    there is the code of my validator
    Code:
    Ext.apply(Ext.form.VTypes, {
    duplicateId : function (val, field){
    var validfield = true;
    Ext.Ajax.request({
      url:'rh/getdata',method:'POST',
      async : false,
      params :{gData:'ifExist',matricule: val },
      success: function(responseObject){
       var resp = responseObject.responseText;
           if (resp == 1) {
                  validfield=false;
               field.markInvalid('Ce matricule est déja attribué à un employé !');                
             } else if (resp == 0) {
                 validfield=true;
    
              field.clearInvalid();
    }},
      failure: function(){return false}});
      
      return validfield;
    
    }
    });
    i check if form is valid before submiting.

    Code:
      submit : function ()
        {
            if (this.getForm().isValid())
            {    
        this.getForm().submit({
             url: 'rh/setdata',
          waitMsg: 'Enregistrement en cours...',
          scope : this,
          method: 'POST',
          success:this.onSuccess,
         failure:this.onFailure,
          params: 
         {
          gData : 'saveEmploye',
          newEmp:this.nouvEmp 
         // matricule:idadds
       }})}
       else
       {this.showError('Veuillez completer votre formulaire','erreur');}
        }
    I have certainly omitted something

  2. #2
    Ext User shibubh's Avatar
    Join Date
    Jul 2007
    Location
    Lamahi,Dang Nepal
    Posts
    449
    Vote Rating
    0
    shibubh is on a distinguished road

      0  

    Default


    Code:
    Ext.apply(Ext.form.VTypes, {
      duplicateId: function(val, field) {
        var validfield = true;
        Ext.Ajax.request({
          url: 'rh/getdata',
          method: 'POST',
          async: false,
          params: {
            gData: 'ifExist',
            matricule: val
          },
          success: function(responseObject) {
            var resp = responseObject.responseText;
            if (resp == 1) {
              validfield = false;
              field.markInvalid('Ce matricule est déja attribué à un employé !');
            } else if (resp == 0) {
              validfield = true;
              field.clearInvalid();
            }
          },
          failure: function() {
            return false
          }
        });
    
        return validfield;// this cause your request valid. because since request ajax so at at that time //we can not say whether the request is success or failure
    
    
      }
    });
    Shibu Bhattarai

    Use JavaScript beautifier to beautify you code http://jsbeautifier.org/

    Code Conventions http://javascript.crockford.com/code.html

    ExtJS Core Manual http://extjs.com/products/extcore/manual/

  3. #3
    Sencha User aityahia's Avatar
    Join Date
    Feb 2009
    Posts
    82
    Vote Rating
    0
    aityahia is on a distinguished road

      0  

    Default


    tanks it's work, soleved

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi