Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional: Add validation method for Polish telephone number
- Loading branch information
1 parent
4d9e485
commit 5651c37
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Polish telephone numbers have 9 digits. | ||
* | ||
* Mobile phone numbers starts with following digits: | ||
* 45, 50, 51, 53, 57, 60, 66, 69, 72, 73, 78, 79, 88. | ||
* | ||
* Fixed-line numbers starts with area codes: | ||
* 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25, 29, 32, 33, | ||
* 34, 41, 42, 43, 44, 46, 48, 52, 54, 55, 56, 58, 59, 61, | ||
* 62, 63, 65, 67, 68, 71, 74, 75, 76, 77, 81, 82, 83, 84, | ||
* 85, 86, 87, 89, 91, 94, 95. | ||
* | ||
* Ministry of National numbers Defence and VoIP numbers starts with 26 and 39. | ||
* | ||
* Excludes intelligent networks (premium rate, shared cost, free phone numbers). | ||
* | ||
* Poland National Numbering Plan http://www.itu.int/oth/T02020000A8/en | ||
*/ | ||
$.validator.addMethod( "phonePL", function( phone_number, element ) { | ||
phone_number = phone_number.replace( /\s+/g, "" ); | ||
var regexp = /^(?:(?:(?:\+|00)?48)|(?:\(\+?48\)))?(?:1[2-8]|2[2-69]|3[2-49]|4[1-68]|5[0-9]|6[0-35-9]|[7-8][1-9]|9[145])\d{7}$/; | ||
return this.optional( element ) || regexp.test( phone_number ); | ||
}, "Please specify a valid phone number" ); |