Skip to main content
johnpauld0002
Participating Frequently
Oct 21, 2021 2:54 AM UTC
Question

Amount Format in IntegerField

Is there any solution in Integerfiel to generate an Amount Format? but in textField my logic is working but my validations is not working. My validation is only numbers can accept in textField.

13 replies

Participating Frequently
Oct 21, 2021 3:34 AM UTC

For simple number validation within text field you can use cleanwith() function. Generally regex is used for more complex validations that involve pattern matching like email formats, etc. 

a!textField(
  label: "Formatted Number",
  value: if(
    or(isnull(ri!formattedNumber), ri!formattedNumber <> cleanwith(ri!formattedNumber, "1234567890.,")),
    ri!formattedNumber,
    text(ri!formattedNumber, "##,###.##")
  ),
  saveInto: ri!formattedNumber,
  validations: {
    if(
      ri!formattedNumber <> cleanwith(ri!formattedNumber, "1234567890.,"),
      "Please input numbers only",
      {}
    )
  }
)

johnpauld0002
Participating Frequently
Oct 21, 2021 4:45 AM UTC

I also tried this but I have problem says "Interface Definition: Expression evaluation error at function 'cleanwith' [line 112]: A null parameter has been passed as parameter 1." 

Inspiring
Oct 21, 2021 4:02 AM UTC

remove that false in if statement and add null and try it

johnpauld0002
Participating Frequently
Oct 21, 2021 4:30 AM UTC

hi avinash. i try that solution but i gave me an error.

...

Inspiring
Oct 21, 2021 4:35 AM UTC

why not try the logic mentioned by hrishikeshd963it works good