Validations for mobile number

Hi,

I have requirement to put validation while entering the mobile number. Actually I have taken text Field component for mobile number and kept the validation using function "len" 

if(len(local!variable) > 10) then I am displaying the error message saying "enter up to 10 digits". But the issue is as I am using text field it even accepting the alphabetical values like "sdfghfghfASSD". But it should not accept alphabetical values, it should accept only digits if the user enters alphabetical values by mistake then it should give the error message.

How does it possible is there any solution? Can anyone please help on this?

 

Note: I have used integer field component too but it allows only digits up to 8.

  Discussion posts and replies are publicly visible

Parents
  • Hi,

    You can validate this by two
    1.
    load(
    local!number:"1234567890",
    like(local!number,"[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]")
    )

    2.
    if(
    isnull(
    ri!mobileNumber
    ),
    null,
    or(
    regexmatch(
    "^(\+\d{1,3}[- ]?)?\d{10}$",
    ri!mobileNumber
    ),
    regexmatch(
    "^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$",
    ri!mobileNumber
    ),
    regexmatch(
    "^\([0-9]{3}\)[0-9]{3}-[0-9]{4}$",
    ri!mobileNumber
    ),
    regexmatch(
    "^\+[0-9]{10,20}$",
    ri!mobileNumber
    )
    ),
    null,
    {
    "Invalid mobile number.",
    "Valid formats (555)555-5555 or 555-555-5555 or 1234567890 or +1234567890"
    }
    )
Reply
  • Hi,

    You can validate this by two
    1.
    load(
    local!number:"1234567890",
    like(local!number,"[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]")
    )

    2.
    if(
    isnull(
    ri!mobileNumber
    ),
    null,
    or(
    regexmatch(
    "^(\+\d{1,3}[- ]?)?\d{10}$",
    ri!mobileNumber
    ),
    regexmatch(
    "^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$",
    ri!mobileNumber
    ),
    regexmatch(
    "^\([0-9]{3}\)[0-9]{3}-[0-9]{4}$",
    ri!mobileNumber
    ),
    regexmatch(
    "^\+[0-9]{10,20}$",
    ri!mobileNumber
    )
    ),
    null,
    {
    "Invalid mobile number.",
    "Valid formats (555)555-5555 or 555-555-5555 or 1234567890 or +1234567890"
    }
    )
Children
No Data