Frequently Asked Questions
Sri Lankan phone numbers follow the E.164 international standard, which includes the +94 country code followed by a 9-digit national number. For example, a valid number would look like +94771234567. Always store numbers in this format for consistency and international compatibility.
Use regular expressions for robust validation. In JavaScript, an example regex is /^(?:0|94|\+94)?([0-9]{9})$/. This checks for a valid 9-digit number, optionally preceded by 0, 94, or +94. Server-side validation is crucial for security.
You can identify the type by the prefix. Mobile numbers typically start with 07[0-8], landlines with 0 followed by a 2-digit area code, and shortcodes are usually 3 or 4 digits. Use this to customize handling in your application.
Storing numbers in E.164 format (+94XXXXXXXXX) ensures consistency and simplifies internationalization. It facilitates compatibility with various telecommunication systems and streamlines processing.
MNP lets users switch operators while keeping their number. Developers should integrate with an MNP lookup service (if available) to determine the current operator and route calls/messages correctly.
Integrate with an MNP lookup service to dynamically identify the current operator for a given number. This is important for accurate routing and billing, especially with number portability.
Common emergency numbers like police (119), ambulance (110), and disaster management (1919) should be dialed directly without prefixes. Implement logic to detect these numbers and handle them appropriately in your application.
Area codes range from 11 for Colombo to 91 for Ampara. They are two digits and precede the 7-digit subscriber number in landline phone numbers. Mobile numbers do not use area codes.
Sri Lanka's network infrastructure varies. Implement network quality detection and fallback mechanisms for areas with limited connectivity. Design features like caching and adaptive bitrate streaming for optimal performance.
The Telecommunications Regulatory Commission of Sri Lanka (TRC) website (http://www.trc.gov.lk) provides the latest regulations, updates, device approval requirements, and licensing information for telecommunications operations.
The international prefix for calling Sri Lanka is 00. Dial 00 followed by 94 (the country code) and then the 9-digit phone number.
Client-side validation enhances user experience by immediately alerting users to formatting errors. It should be used in conjunction with server-side validation for data integrity and security.
Yes, you can identify shortcodes by checking for numbers that are typically 3 or 4 digits long. In your code, use regular expressions or other pattern matching techniques to distinguish them from regular phone numbers.
Sri Lanka Phone Number Validation: Complete Guide to +94 Format & Implementation
Learn how to validate Sri Lanka phone numbers (+94 country code) using E.164 format standards. This comprehensive guide covers phone number validation patterns, TRC (Telecommunications Regulatory Commission) regulations, mobile operator prefixes for Dialog, Mobitel, Hutch, and Airtel, JavaScript validation code, area codes, and emergency number handling for Sri Lankan telecommunications applications.
Quick Reference
Sri Lanka Phone Number Format and Validation
Sri Lanka phone number validation requires understanding the country's E.164-compliant numbering system. The Telecommunications Regulatory Commission (TRC) regulates all Sri Lanka phone numbers, which use the +94 country code and a 10-digit national format (including trunk prefix 0).
E.164 Format Structure for Sri Lanka Numbers
How to Identify Sri Lanka Number Types by Prefix
Mobile Numbers – Begin with 070-078 (10 digits total):
Landline Numbers – Format:
0XX Y ZZZZZZ
0XX
: 2-digit area codeY
: Operator codeZZZZZZ
: 6-digit subscriber numberMajor area codes:
Short Codes – 3 or 4 digits for emergency and special services
Important: Mobile operator prefixes indicate original network assignment. Due to Mobile Number Portability (MNP), subscribers can switch operators while keeping their numbers.
Validation Implementation with Regular Expressions (Regex)
Store numbers in E.164 format (+94XXXXXXXXX) for consistency and international compatibility.
Validate user input with regular expressions:
Identify number types based on prefix patterns:
Mobile Number Portability (MNP)
Sri Lanka supports MNP, allowing subscribers to switch operators while keeping their numbers. Implement lookup mechanisms to determine the current operator.
Integrate MNP lookup service for accurate operator identification:
Route calls based on operator to ensure efficient delivery:
Emergency Numbers
All emergency numbers are toll-free and accessible from any phone, even with low signal or credit. Never apply prefixes, rate limiting, or validation restrictions to these numbers.
Primary Emergency Services:
Security and Defense:
Specialized Support:
Operator Customer Service:
Source: TRC 3-Digit Short Codes for Special Services
Implement emergency detection:
Network Considerations
Sri Lanka has mixed urban and rural network infrastructure. Design your application to handle varying connectivity.
Detect network quality and provide fallbacks:
Implement coverage-aware features:
Compliance and Regulations
Follow TRC regulations to ensure legal compliance:
Error Handling
Provide clear, actionable error messages that explain what went wrong and how to fix it.
Example error handling:
Handle common scenarios:
Frequently Asked Questions (FAQ)
What is the country code for Sri Lanka phone numbers?
Sri Lanka's country code is +94. When dialing Sri Lanka from abroad, dial +94 followed by the 10-digit number (without the leading 0). Within Sri Lanka, dial the full 10-digit number including the leading 0.
How many digits are in a Sri Lanka phone number?
Sri Lanka phone numbers have 10 digits in the domestic format (including the trunk prefix 0). When using the international format with the country code, it's +94 followed by 9 digits (the 10-digit number without the leading 0).
What is the format for Sri Lanka mobile numbers?
Sri Lanka mobile numbers are 10 digits starting with 070, 071, 072, 074, 075, 076, 077, or 078:
Due to Mobile Number Portability (MNP), these prefixes indicate the original network but not necessarily the current operator.
How do I validate a Sri Lanka phone number in JavaScript?
Use regular expressions to validate Sri Lanka phone numbers. Check for domestic format (10 digits starting with 0) or international format (+94 followed by 9 digits). Always sanitize input by removing spaces, hyphens, and parentheses before validation.
What are Sri Lanka landline area codes?
Sri Lanka landline area codes are 2-digit numbers that identify geographic regions:
Landlines follow the format: 0XX Y ZZZZZZ (area code + operator code + 6-digit number).
What is the emergency number in Sri Lanka?
Sri Lanka has multiple emergency numbers:
All emergency numbers are toll-free and accessible even with low signal or credit.
Does Sri Lanka support mobile number portability?
Yes, Sri Lanka supports Mobile Number Portability (MNP), allowing subscribers to switch between operators (Dialog, Mobitel, Hutch, Airtel) while keeping their existing phone numbers. For accurate carrier identification, use an MNP lookup service instead of relying solely on number prefixes.
Who regulates Sri Lanka phone numbers?
The Telecommunications Regulatory Commission of Sri Lanka (TRC) regulates the country's phone numbering system and telecommunications services. The TRC ensures compliance with international E.164 standards and manages the national numbering plan. Visit http://www.trc.gov.lk for official regulations.
Additional Resources
Conclusion
Validating Sri Lanka phone numbers requires understanding E.164 format standards, TRC regulations, and the country's 10-digit numbering system with +94 country code. This guide provides production-ready validation patterns, operator identification methods, and regulatory compliance requirements for implementing robust Sri Lanka phone number validation.
Key takeaways:
Implement the JavaScript validation functions provided in this guide, expand them with comprehensive error handling, and ensure your application follows security best practices for telecommunications data.
Related topics: