prevent user entering text or symbol in a!textdield

Hi,

I am displaying a decimal value in   a!textField as part of an editable grid . 

I would like to put some validation if the user enters a text in this field it should throw error or blank out . 

 

 a!textField(
            value: if(todecimal(ri!items[ri!index].currentMonDis)=0,"",dollar(ri!items[ri!index].currentMonDis)),
          saveInto:{
              ri!items[ri!index].currentMonDis,
             a!save(ri!itemstoken,append(ri!itemstoken,save!value)),
              a!save(ri!items[ri!index].changeOrdiff,todecimal(ri!items[ri!index].currentMonDis)-todecimal(ri!items[ri!index].lastMonDis)),
               a!save(ri!itemstoken,append(ri!itemstoken,todecimal(ri!items[ri!index].currentMonDis)-todecimal(ri!items[ri!index].lastMonDis)))
            }
           
          ),

 

at present , if we enter any text it throws the error message below 

 

Error Evaluating UI Expression
Expression evaluation error in rule 'eds_showitemroweach' (called by rule 'eds_initiaterbepaymentreview') at function a!applyComponents [line 188]: A null parameter has been passed as parameter 1.

 

Can you provide any ideas to prevent user entering text or symbols in this field ?

 

  Discussion posts and replies are publicly visible

Parents
  • You can and should still use the text field so that you have the option of the dollar() function. When saving the data in the value to your ri!, which I assume is a Decimal type, you need to wrap it in an if(). All other text that isn't decimal returns a null value when you try to use toDecimal() and store it in a Decimal type. This is your isDecimal function already built.

    a!save( ri!yourDecimal, if(APN_isBlank(toDecimal(save!value)), 0.0, toDecimal(save!value) )

    The save above saves a 0.0 instead of null if the toDecimal comes back null. This should render any attempt to type anything else like "Lorem Ipsum" into your decimal into a 0.0. If you don't have access to APN_isBlank, isNull() should also give the same result. No regex needed; sorry regex fans.
Reply
  • You can and should still use the text field so that you have the option of the dollar() function. When saving the data in the value to your ri!, which I assume is a Decimal type, you need to wrap it in an if(). All other text that isn't decimal returns a null value when you try to use toDecimal() and store it in a Decimal type. This is your isDecimal function already built.

    a!save( ri!yourDecimal, if(APN_isBlank(toDecimal(save!value)), 0.0, toDecimal(save!value) )

    The save above saves a 0.0 instead of null if the toDecimal comes back null. This should render any attempt to type anything else like "Lorem Ipsum" into your decimal into a 0.0. If you don't have access to APN_isBlank, isNull() should also give the same result. No regex needed; sorry regex fans.
Children
No Data