Function to check if input is non-numeric or numeric

Is there any function to check whether the entered input is non-numeric or numeric?

Thanks!...

OriginalPostID-106178

OriginalPostID-106178

  Discussion posts and replies are publicly visible

Parents
  • I've created a custom expression rule to validate this in the past. Basically in the expression rule you need to convert the text input to int then compare it to the original. Something like this will demonstrate:
    if( int(ri!text) = trim(ri!text), "valid integer", "not a valid integer")

    For your actual expression rule you'll naturally want it to just return true() or false().
    Note that i use trim() in this expression; this might be necessary to keep a valid integer from returning invalid in the case that any extra white space is passed in.
Reply
  • I've created a custom expression rule to validate this in the past. Basically in the expression rule you need to convert the text input to int then compare it to the original. Something like this will demonstrate:
    if( int(ri!text) = trim(ri!text), "valid integer", "not a valid integer")

    For your actual expression rule you'll naturally want it to just return true() or false().
    Note that i use trim() in this expression; this might be necessary to keep a valid integer from returning invalid in the case that any extra white space is passed in.
Children
  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    Hello Mike used your suggestion also added some my inputs so as to use the code for all types of rule input limitation is input cannot extend more than integer size then it won't catch int field appropriately. if any comments on this code snippets would help me understand missing cases and scenarios


    )

    a!localVariables(
      local!b: trim(ri!id),
      if(
        a!isNullOrEmpty(tointeger(ri!id)),
        false,
        if(int(ri!id) = local!b, true, false)
      )
    )