Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Danish Update #2165

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/additional/phoneDK.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Matches DK phone number format
*
* allows '-' or ' ' as a separator and allows parens around area code
* some people may want to put a '+45' in front of their number
*
* +45 21-77-21-77
* +45 21 77 21 77
* +45 21772177
* +4521772177
* 21 77 21 77
* 21-77-21-77
* 2177 2177
* 2177-2177
* 21772177
*
* but not
* +1 3243121212
* +45 112
* +452143284233
* 2143284233
*/
$.validator.addMethod( "phoneDK", function( phone_number, element ) {
phone_number = phone_number.replace( /\s+/g, "" );
return this.optional( element ) || phone_number.length > 9 &&
phone_number.test( /^(?:\+45(?: )?)?(?:[0-9]{2})(?:(?:-| )?[0-9]{2})(?:(?:-| )?[0-9]{2})(?:(?:-| )?[0-9]{2})$/ );
}, "Please specify a valid phone number" );
12 changes: 12 additions & 0 deletions src/additional/postalcodeDK.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Danish Kingdom Postal codes
*
* This accept all Danish(DK) kingdom postal codes (100 to 9999)
* also work for the Danish kingdom Greenland and Faroe Islands.
*
* Note: Greenland and Faroe Islands is a part of the Danish Kingdom and not the country it self.
*/

$.validator.addMethod( "postalcodeDK", function( value, element ) {
return this.optional( element ) || /^[0-9]{3,4}$/.test( value );
}, "Please specify a valid postal code" );
4 changes: 3 additions & 1 deletion src/localization/messages_da.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ $.extend( $.validator.messages, {
maxWords: $.validator.format( "Indtast venligst højst {0} ord" ),
step: $.validator.format( "Angiv en værdi gange {0}." ),
notEqualTo: "Angiv en anden værdi, værdierne må ikke være det samme.",
integer: "Angiv et ikke-decimaltal, der er positivt eller negativt."
integer: "Angiv et ikke-decimaltal, der er positivt eller negativt.",
phoneDK: "Angiv et gyldigt telefonnummer.",
postalCodeDK: "Angiv venligst et gyldigt postnummer."
} );