Skip to content

Commit

Permalink
Additional: Add validation method for Polish telephone number
Browse files Browse the repository at this point in the history
  • Loading branch information
skotniczny authored and Arkni committed Feb 13, 2018
1 parent 4d9e485 commit 5651c37
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/additional/phonePL.js
@@ -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" );

0 comments on commit 5651c37

Please sign in to comment.