Skip to content

Persian date #1038

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

Closed
wants to merge 2 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
3 changes: 3 additions & 0 deletions src/additional/dateFA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
jQuery.validator.addMethod("dateFA", function(value, element) {
return this.optional(element) || /^[1-4]\d{3}\/((0?[1-6]\/((3[0-1])|([1-2][0-9])|(0?[1-9])))|((1[0-2]|(0?[7-9]))\/(30|([1-2][0-9])|(0?[1-9]))))$/.test(value);
}, "Please enter a correct date");
5 changes: 4 additions & 1 deletion src/localization/messages_fa.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
email: ".لطفا یک ایمیل صحیح وارد کنید",
url: "لطفا آدرس صحیح وارد کنید.",
date: "لطفا یک تاریخ صحیح وارد کنید",
dateFA: "لطفا یک تاریخ صحیح وارد کنید",
dateISO: "لطفا تاریخ صحیح وارد کنید (ISO).",
number: "لطفا عدد صحیح وارد کنید.",
digits: "لطفا تنها رقم وارد کنید",
Expand All @@ -20,6 +21,8 @@
rangelength: $.validator.format("لطفا مقداری بین {0} تا {1} حرف وارد کنید."),
range: $.validator.format("لطفا مقداری بین {0} تا {1} حرف وارد کنید."),
max: $.validator.format("لطفا مقداری کمتر از {0} حرف وارد کنید."),
min: $.validator.format("لطفا مقداری بیشتر از {0} حرف وارد کنید.")
min: $.validator.format("لطفا مقداری بیشتر از {0} حرف وارد کنید."),
minWords: $.validator.format("لطفا حداقل {0} کلمه وارد کنید."),
maxWords: $.validator.format("لطفا حداکثر {0} کلمه وارد کنید.")
});
}(jQuery));
22 changes: 22 additions & 0 deletions test/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,29 @@ test("dateITA", function() {
ok(!method( "01/01/199" ), "Invalid date ITA" );
});

test("dateFA", function() {
var method = methodTest("dateFA");

ok( method( "1342/12/29" ), "Valid date FA" );
ok( method( "1342/12/30" ), "Valid date FA" );
ok( method( "1361/6/31" ), "Valid date FA" );
ok( method( "1321/11/30" ), "Valid date FA" );
ok( method( "1361/1/1" ), "Valid date FA" );
ok( method( "1020/3/3" ), "Valid date FA" );
ok( method( "1020/03/3" ), "Valid date FA" );
ok( method( "1020/3/03" ), "Valid date FA" );
ok( method( "1020/03/03" ), "Valid date FA" );
ok( method( "1001/7/30" ), "Valid date FA" );

ok(!method( "1000/1/32" ), "Invalid date FA" );
ok(!method( "1323/12/31" ), "Invalid date FA" );
ok(!method( "1361/0/11" ), "Invalid date FA" );
ok(!method( "63/4/4" ), "Invalid date FA" );
ok(!method( "15/6/1361" ), "Invalid date FA" );
});

test("iban", function() {

var method = methodTest("iban");
ok( method( "NL20INGB0001234567"), "Valid IBAN");
ok( method( "DE68 2105 0170 0012 3456 78"), "Valid IBAN");
Expand Down