HI
How do i restrict the number of digits for a telephone number?
only the number like that : 77 ### ## ## or 76 ### ## ## or 70 ### ## ## or 33 ### ## ## teh interview can enter
please help urgent
HI
How do i restrict the number of digits for a telephone number?
only the number like that : 77 ### ## ## or 76 ### ## ## or 70 ### ## ## or 33 ### ## ## teh interview can enter
please help urgent
It seems that you are going for a text question with a pre-determined pattern. Assume this variable is called βtelephone_numberβ:
Iβd also use this approach in this scenario.
But use pattern: ## ### ## ## to allow only numeric characters.
To check the correct value at the first two digits, and if it is indeed just about those 4 digit combinations, the simplest approach that comes to my mind:
2a) Get the value of the first two digits through
telephone_number.Left(2)
2b) Validate that it is only any of your desired values:
telephone_number.Left(2).Contains("70") || telephone_number.Left(2).Contains("76") || telephone_number.Left(2).Contains("77") || telephone_number.Left(2).Contains("30")
You can also use self.Left(2).Contains("77")...
if you are using it as a validation condition at variable βtelephone_numberβ.
Best,
Peter
Thank you so much itβs done and it works
Itβs easier to search the actual input in the whitelist:
"33 70 76 77".Contains(self.Left(2))
Another approach could be to ask for the operator first (e.g. ATT, T-Mobile, Vodafone, β¦) then accept only codes specific to a particular operator (not much advantage if they use multiple codes plus the respondent may not necessarily know the operator).
Best, Sergiy