[SOLVED] Value saved as "text" instead of "number" type

Hi everyone!

I have my code where I recollect data from my input ( $w ( #input2 ) ), it has to be a number.

Here the issue is that, when it is submitted, the information that arrives to the database is a “text” format, and it does not read it as a “number” type (see my image, the last column named “Cantidad”).

Does anyone has a solution or something for this?

My code looks like this (I just pasted here the code part that interacts with my input $w ( #input2 ) ):


import wixData from ‘wix-data’ ;

$w ( ‘#input2’ ). required ;
$w ( “#input2” ). inputType = “number” ;

  $w ( "#input2" ). onKeyPress ( event  => { 
    setTimeout (() => { validateInput ();},  10 ) 
  }) 

  function  validateInput (){ 
    let  value  =  $w ( "#input2" ). value ; 
    if  (/[a-z]/. test ( value . toLowerCase ())){ 
    $w ( "#input2" ). value  =  "" ; 
    } 
  } 

export function button2_click ( event ) {

$w ( ‘#input2’ ). required ;

if ( $w ( ‘#input2’ ). value === “” ){
$w ( ‘#Error’ ). show ();
$w ( ‘#message’ ). hide ();
$w ( ‘#input2’ ). style.backgroundColor = “#C23B22” ;
console . error ();
}

if ( $w ( ‘#input2’ ). valid ) {

$w ( "#input2" ). inputType  =  "number" ; 
$w ( '#message' ). show (); 
$w ( '#Error' ). hide (); 

let  cantidad  =  $w ( '#input2' ). value 

let  toInsert  = { 
   "cantidad" :  cantidad , 
  }; 

  wixData . insert ( "Entradas" ,  toInsert ) 
   . then (( results ) => { 
   console . log ( results ); 
  }) 

  $w ( '#input2' ). value  =  "" ; 

  $w ( '#input2' ). resetValidityIndication (); 

  . catch (( err ) => { 
   console . log ( err ); 
  });       

}
}
}
}

}


 let cantidad = Number($w('#input2').value);

Works so well! Thank you so much, J.D. :grin: