Skip to main content
October 26, 2023
Question

validation message

  • October 26, 2023
  • 11 replies
  • 0 views

Hi all,

I need to validate that in a texfield, the user on type characters, I mean (100k, 80k, ect), numbers with text values.

if the user enters 10k,20k like in textfield, I have show some validation message,How could I achieve this,

is there a special functions?

Can anyone help me please on priority?

    11 replies

    jonesprakashs0001
    October 26, 2023

    Hi [mention:ef0fbf994c9643cd84ee894e18f03e86:e9ed411860ed4f2ba0265705b8793d05],

    One suggestion here is that we can directly use the integer field. If there is a different constraint, I have added the code for validation for the text field you expected below.

    {
      a!textField(
        label: "Text",
        labelPosition: "ABOVE",
        value: ri!text,
        saveInto: ri!text,
        validations: if(
          and(
            a!forEach(
              items: code(ri!text),
              expression: and(fv!item >= 48, fv!item <= 57)
            )
          ),
          "",
          "Enter a valid number"
        )
      )
    }

    October 26, 2023

    Hi, this works for integer data type, But in my case I have number(decimal) data type.If I use this validation it is not working for me,what to do?

    jonesprakashs0001
    October 26, 2023

    In the case of decimals, use the decimal field component which has inbuilt validations to avoid text

    https://docs.appian.com/suite/help/23.3/Floating_Point_Component.html

    navajithh
    October 26, 2023

    Try this: 

    a!localVariables(
    local!a,
    a!textField(
    label:"Number Only",
    value:local!a,
    saveInto: local!a,
    validations: if(a!isNullOrEmpty(stripwith(local!a,"0123456789")),"","validation"),
    )
    )

    October 26, 2023


    I have done like this,still it not working,Could you suggest?

     a!textField(
                    /*label:"Market Value"*/
                    value: rule!CR_FN_setDecimalValues(
                      value_dec: index(fv!item, "marketValue_dec", {}),
                      decPlace_int: 2
                    ),
                    saveInto: {
                      fv!item.marketValue_dec,
                      a!save(
                        fv!item.discountedValue_int,
                        rule!CR_APP_FN_getDiscountedValueFromMarketValue(
                          crREFCollateral_cdt: local!rowREFCollateral_cdt,
                          marketValue_dec: fv!item.marketValue_dec
                        )
                      )
                    },
                    readOnly: local!releaseDeleteReadOnlyBool,
                    required: rule!CR_APP_FN_requiredConditionsForDocumentaionUnit(
                      crAppSelectedItem_cdt: fv!item,
                      role_txt: ri!role_txt,
                      isRequired_bool: ri!isSecurityCollateralReq_bool
                    ),
                    validations: {rule!CR_FN_setValueGreaterThanZeroValidation(value_dec: fv!item.marketValue_dec),
                    if(a!isNullOrEmpty(stripwith(local!marketValue,"0123456789")),"","Enter a valid number"),
                    }
                  )

    navajithh
    October 27, 2023

    I don't see any values saved to local!marketValue, which you have used in the stripwith function. In case of decimals, add a decimal point also in the with parameter value of stripwith function.