Enter 10 digit numbers only and should not allow alphabets

Hi All,

I am working on a process which involves typing data into a web application which should not allow alphabets, and should allow number which have only 10 digits.

Can anyone suggest on how to get both the conditions applied ?

Hi @Abc_Xyz1
Check the input string.isnumeric
If yes proceed the process

@Abc_Xyz1 You can use regular expression to get only number from variable

If I enter alphabets it should not allow and it should allow digits more dan 10.These are the two conditions

@Abc_Xyz1
Inputstring.isnumeric and inputstring.length>=10

Hi @Abc_Xyz1 ,

Could you maybe clarify these points ? Do you want to allow only 10 Digits or 10 or more digits ?

Only 10 and no alphabets

@Abc_Xyz1 ,

Try with the below in If Condition :

YourStringVar.IsNumeric andAlso YourStringVar.Length = 10

@Abc_Xyz1
Hello, easiest way is combining what others have said in a Flow Chart with the Flow Decision:
YourInput.IsNumeric And YourInput.Length = 10
image
Regards

@Abc_Xyz1
Another option is a Do While:


Regards

1 Like
  1. Use the “Input Dialog” or “Get Text” activity to get the input from the user.
  2. Use the “Regular Expression” activity to check if the input matches the pattern for 10 digit numbers.
  3. Use a “If” activity to check the output of the regular expression activity.
  4. If the output is true, it means that the input is valid and the process can continue. If the output is false, the input is not valid and the process can be stopped or a message displayed to the user.
    The pattern used in this example is “^\d{10}$” which means that the input must start with a digit (\d), have exactly 10 digits, and must end with a digit.
    Regex pattern = “^\d{10}$”

string input = InputDialog(“Enter a 10 digit number”)

Match match = Regex.Match(input, pattern)

if(match.Success)
{
//input is valid
//process can continue
}
else
{
//input is not valid
//process can be stopped or a message displayed to the user
}

This is a simple example, you can also use other regex validation to match the desired input format.

1 Like