Write one validation rule in contact object in phone field
First requirement is 10 numbers are mandatory & in 10 numbers first two numbers are between 7-9 and remaining between 0-9 ?
I have cellular phone numbers I need to run query against another table with celluar phone numbers but specific cells in the phone number column have +1 before the phone number and specific cells do not have +1 in front of cellular phone numbers.
Where specific cells in a column have +1 in front of the cellular phone number how to modify by removing +1 if exists.
Usually the cellular phone numbers are 10 digits in length. So, You can select the Phone numbers which are greater than the length of 10 and overwrite those values with the last 10 digits (length_Of_Cell_Value-10 to length_Of_Cell_Value). So that the exact phone number without the country code is overwritten at the respective cell value..
So far i tried doing this, but it is wrong
Phone like '[0-2][0-2][0-2][0-2]'
Right now you check, if the phone number consists only of four digits between 0 and 2. You need to add wildcards if there can be more characters in the phone number.
If the four digits can appear anywhere in the string use:
CHECK (phone LIKE '%[0-2][0-2][0-2][0-2]%')
If they can only appear at the beginning use:
CHECK (phone LIKE '[0-2][0-2][0-2][0-2]%')
If they can only appear at the end use:
CHECK (phone LIKE '%[0-2][0-2][0-2][0-2]')
I have to validate the brazil phone no, in brazil phone can be started with zero and it will be 8 digits
I have given <input type="number" name="mobileNo" ng-model="booking.phone" ng-pattern="/^[0-9]{8,8}$/" required placeholder="Phone no">
validation is working fine if i given something like "25869859"
But if i have given as "02587895" it is not counting the first number if it is start with zero, it is taking 9 digits
what is need is it should take only 8 digits even if i given number starting with zero
Try change the Quantifier: ^[0-9]{8,9}$
Quantifier - {8,9} Matches between 8 and 9 times
Or if you want to verify 0, try:
^0?[0-9]{8,8}$
0? matches the character 0 literally between zero and one times, as many times as possible, giving back as needed
Demo
What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone.
considerations:
+ for country code
() for area code
x + 6 numbers for Extension extension (so make it 8 {space})
spaces between groups (i.e. in American phones +x xxx xxx xxxx = 3 spaces)
here is where I need your help, I want it to be worldwide
Consider that in my particular case now, I don't need cards etc. number begins with country code and ends with the extension, no Fax/Phone etc. comments, nor calling card stuff needed.
Assuming you don't store things like the '+', '()', '-', spaces and what-have-yous (and why would you, they are presentational concerns which would vary based on local customs and the network distributions anyways), the ITU-T recommendation E.164 for the international telephone network (which most national networks are connected via) specifies that the entire number (including country code, but not including prefixes such as the international calling prefix necessary for dialling out, which varies from country to country, nor including suffixes, such as PBX extension numbers) be at most 15 characters.
Call prefixes depend on the caller, not the callee, and thus shouldn't (in many circumstances) be stored with a phone number. If the database stores data for a personal address book (in which case storing the international call prefix makes sense), the longest international prefixes you'd have to deal with (according to Wikipedia) are currently 5 digits, in Finland.
As for suffixes, some PBXs support up to 11 digit extensions (again, according to Wikipedia). Since PBX extension numbers are part of a different dialing plan (PBXs are separate from phone companies' exchanges), extension numbers need to be distinguishable from phone numbers, either with a separator character or by storing them in a different column.
Well considering there's no overhead difference between a varchar(30) and a varchar(100) if you're only storing 20 characters in each, err on the side of caution and just make it 50.
In the GSM specification 3GPP TS 11.11, there are 10 bytes set aside in the MSISDN EF (6F40) for 'dialing number'. Since this is the GSM representation of a phone number, and it's usage is nibble swapped, (and there is always the possibility of parentheses) 22 characters of data should be plenty.
In my experience, there is only one instance of open/close parentheses, that is my reasoning for the above.
It's a bit worse, I use a calling card for international calls, so its local number in the US + account# (6 digits) + pin (4 digits) + "pause" + what you described above.
I suspect there might be other cases
As for "phone numbers" you should really consider the difference between a "subscriber number" and a "dialling number" and the possible formatting options of them.
A subscriber number is generally defined in the national numbering plans. The question itself shows a relation to a national view by mentioning "area code" which a lot of nations don't have. ITU has assembled an overview of the world's numbering plans publishing recommendation E.164 where the national number was found to have a maximum of 12 digits. With international direct distance calling (DDD) defined by a country code of 1 to 3 digits they added that up to 15 digits ... without formatting.
The dialling number is a different thing as there are network elements that can interpret exta values in a phone number. You may think of an answering machine and a number code that sets the call diversion parameters. As it may contain another subscriber number it must be obviously longer than its base value. RFC 4715 has set aside 20 bcd-encoded bytes for "subaddressing".
If you turn to the technical limitation then it gets even more as the subscriber number has a technical limit in the 10 bcd-encoded bytes in the 3GPP standards (like GSM) and ISDN standards (like DSS1). They have a seperate TON/NPI byte for the prefix (type of number / number plan indicator) which E.164 recommends to be written with a "+" but many number plans define it with up to 4 numbers to be dialled.
So if you want to be future proof (and many software systems run unexpectingly for a few decades) you would need to consider 24 digits for a subscriber number and 64 digits for a dialling number as the limit ... without formatting. Adding formatting may add roughly an extra character for every digit. So as a final thought it may not be a good idea to limit the phone number in the database in any way and leave shorter limits to the UX designers.
Digits range for all countries 4 - 13 https://en.wikipedia.org/wiki/List_of_mobile_telephone_prefixes_by_country