In the same table I have a field called COUNTRY and another called CELL_NUMBER.
Only in the case that the country is "XXXX" I want to validate that the cell phone number meets the following conditions:
- The length must be 9 characters
- Must start with 0
Could someone give me a hand with this?
Solved! Go to Solution.
IFS([Country] = "XXXX", AND(LEN([_THIS]) = 9, STARTSWITH([_THIS], "0"))
IFS([Country] = "XXXX", AND(LEN([_THIS]) = 9, STARTSWITH([_THIS], "0"))
Perfect !!! The only detail is that a parenthesis is missing at the end !!! Thank you very much for the collaboration
IFS([pais_celular] = "Uruguay", AND(LEN([_THIS]) = 9, STARTSWITH([_THIS], "0")))
You can use the following formula:
AND(
[COUNTRY] = "XXXX",
LEN([CELL_NUMBER]) = 9,
LEFT([CELL_NUMBER], 1) = "0"
)
Let's break down the expression:
- `[COUNTRY] = "XXXX"`: This condition checks if the value in the COUNTRY field is equal to "XXXX". Replace "XXXX" with the actual country code you want to validate.
- `LEN([CELL_NUMBER]) = 9`: This condition checks if the length of the CELL_NUMBER field is exactly 9 characters.
- `LEFT([CELL_NUMBER], 1) = "0"`: This condition checks if the first character of the CELL_NUMBER field is "0".
The `AND` function is used to combine these conditions, and it will return true only if all the conditions are met.
To use this expression for validation, you can apply it in different contexts, such as in a Valid_If constraint or a column's Valid If property. For example, if you want to use it as a Valid_If constraint for the CELL_NUMBER field, you can set the Valid_If property of the CELL_NUMBER field to:
AND(
[COUNTRY] = "XXXX",
LEN([CELL_NUMBER]) = 9,
LEFT([CELL_NUMBER], 1) = "0"
)
Replace "XXXX" with the actual country code you want to validate.
By using this expression, the CELL_NUMBER field will only be considered valid if the COUNTRY is "XXXX", the length is 9 characters, and it starts with "0". Otherwise, the validation will fail.
You have given me a good clue but I think that I still have not fully solved the problem. I would like to validate the length of the text and that the beginning is 0 only when the chosen country is URUGUAY. With this formula I understand that if, for example, they choose FINLAND as the country, the response of the AND function will be FALSE and it will not let me enter the data that is surely valid. I DO NOT WANT to restrict that the user can only choose URUGUAY as a country. I want them to be able to choose from the list of 251 countries that I have BUT if the selected one is URUGUAY, they must validate that the length is 9 characters and that it starts with 0.
User | Count |
---|---|
16 | |
9 | |
9 | |
7 | |
3 |