How to give validation rule for Mobile number

0
Hi, I Have application where mobile number attribute should take only 10 digit number not more not less? 
asked
4 answers
3

Hi Poola,

You can use the following regular expression to match a 10-digit mobile number:

^\d{10}$ 
 

Let me know if you face any issues,

Hope it helps!!

 

 

answered
2

Hello Pujitha,

 

The above suggestions also make sense. Here are a few changes to the above solution, where will be using the Mendix provided configurations to handle the required validation as per your requirement;

 

  1. Try creating the variable “PhoneNumber” in the domain model with INTEGER datatype as shown below.
  2. Next, wherever you are using the above variable on a page in the text box, it should be configured as below; The Input mask will guide and limit the user from entering only NUMERIC of specific length.(In this case 10) 
  3. With the above changes the behavior will be something like the below;
  4. This field will not allow you to enter any other value apart from NUMERIC and the moment the user moves out of the field automatically the validation will be triggered(default behavior of Mendix). and will restrict you from entering more than 10 digits.
  5.  

I hope this answers your question.
 

 

But if you have a requirement like the below;

  1. Showing a Custom validation message, like “Invalid phone number”
  2. If the phone number should start from a range of digits like 5-9 (Indian mobile numbers).

Then you need to write an OnChange event and use regular expressions to validate the data. Which will help you to address the issue more precisely.

 

 

answered
0

Hi,

I am Jhansi!

Your Mobile Number should be string and length limited to 10. Please take a look below.

 

Your input field input mask as 9 nine’s and no. Please check the configuration in the below screenshot

 Then add an ON change microflow

Which will validate the length.

 

Hope you find it helpful!!

 

this would be the best solution!

answered
0

Hello Poola Poojitha

1.First in the form create a onchange microflow for that field (i.e Phone number field attribute) as shown below First in the form create a onchange microflow for that field (i.e Phone number field attribute) as shown below

 

2.Later in that microflow place a Decision actity ,in that procced with the expression as mentioned below 

 

Hope it will work for you please reach if anything required

answered