Validate with ajax

Hi,
Can’t to get working item validation . It seems that direct to mine validation function twice . What I’m doing wrong ?

Form :

      function newUzs()
      {
         var lRet = false;
	 var myForm,formData,myComb1;
         var dhxWins,w1;
         formData = [
         {
            type       : "settings", 
            position   : "label-left",
            labelWidth : 120,
            inputWidth : 200
         },
         {
            type      : "input",
            label     : ( $app_lng == "lt" ? "Užsakymo ID" : "Order ID" ),
            name      : "uzsak",
	    maxLength : 20,
	   validate  : "NotEmpty,uzs_valid",
            value     : "",
 	    required  : true
         },
         {
            type      : "input",
            label     : ( $app_lng == "lt" ? "Modelis" : "Model" ),
            name      : "model",
	    maxLength : 30,
	    validate  : "NotEmpty",
            value     : "",
	    required  : true
         },
         {
            type  : "input",
            label : ( $app_lng == "lt" ? "Spalva" : "Color" ),
            name  : "mod_color",
            value : ""
         },
         {
            type         : "input",
            label        : ( $app_lng == "lt" ? "Kiekis" : "Quantity" ),
            name         : "kiek",
            value        : 0,
	    numberFormat : "000000",
	    validate     : "[0-9]+",
	    required     :true
         },
         {
            type  : "input",
            label : ( $app_lng == "lt" ? "Pokav.lapo modelis" : "Pack.list model" ),
            name  : "pl_mod",
            value : " "
         },
         {
            type: "combo",
            label : ( $app_lng == "lt" ? "Kerpa" : "Cutting" ),
            name  : "wcut",
            options: 
            [ 
               {
                  text     : "Zarasai",
                  value    : "Zarasai", 
                  selected : true 
               }, 
               {
                  text     : "Danija",
                  value    : "Danija"
               },
            ]
         },
         {
            type  : "button",
            name  : "gerai",
            value : "Irašyti"
         }];

         var aukstis = 35 + 20 * 16;
         dhxWins = new dhtmlXWindows();
         dhxWins.enableAutoViewport( false );
         dhxWins.attachViewportTo( tabbar.cells( tabbar.getActiveTab() ) );
         w1 = dhxWins.createWindow( "new_uzs", 10, 10, 360, aukstis );
         dhxWins.window( "new_uzs" ).setText( ( $app_lng == "lt" ? "Naujas įrašas !" : "New record !" ) );
         myForm = w1.attachForm( formData );
	myForm.enableLiveValidation( true );
			
         myForm.attachEvent( "onButtonClick", function( id ) 
         {
		var cFlds = "uzsak,preke,uzs_spalv,uzs_kiekis,pok_lap_mod,kerpa,db";
 	        var cVars = "'" + myForm.getItemValue( 'uzsak' ) + "','" + 
						myForm.getItemValue( 'model' ) + "','" + 
						myForm.getItemValue( 'mod_color' ) + "'," +
						myForm.getItemValue( 'kiek' ) + ",'" +
						myForm.getItemValue( 'pl_mod' ) + "','" +
						myForm.getItemValue( 'wcut' ) + "','" + $app_db + "'";
					   
 	         debugger;
		  $.ajax(
                  {
                      url: 'uzsn.php',
                     type: 'GET',
                     data: { fld: cFlds, nvr: cVars },
                     success: function( ret_data )
                     {
 			 if ( ret_data == "yra" )
			     w1.close();
			     lRet = true;
                     }
                  });
         });
         return lRet;
      }    
      
      function uzs_valid( value )
      {
         var lRtn = false;
	 $.ajax(
         {
            url: 'uzschk.php',
            type: 'GET',
            data: { uzs: value, db: $app_db },
            success: function( ret_data )
            {
               debugger;
  	       lRtn = ( ret_data == "0" ? true : false ); 
            }
         });
         debugger;
	 return lRtn;
      }

The function uzs_valid() at first not direct to php code at first time and then second time it direct . The same and with after “onButtonClick” …

Thanks in advance ! With best regards !

Found dhtmlxAjax - that solved this mine problem … :slight_smile: Thanks !