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

Adjust Date Limits for Sample Collection Info #303

Merged
merged 1 commit into from
Dec 1, 2023
Merged
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
54 changes: 28 additions & 26 deletions microsetta_interface/templates/sample.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,35 @@
//expected localized date format matching the datepicker settings.
}, "{{ _('Required Format: MM/DD/YYYY') }}");

$.validator.addMethod("dateInPast", function(value, element)
{
let check;
let date = new Date($("#sample_date_normalized").val());
var lower_limit = new Date();
lower_limit.setFullYear(lower_limit.getFullYear() - 10);
if(date < lower_limit) {
check = false;
} else {
check = true;
}
return this.optional(element) || check;
}, "{{ _('Please select a date within the last 10 years.') }}");
{% if not admin_mode %}
$.validator.addMethod("dateInPast", function(value, element)
{
let check;
let date = new Date($("#sample_date_normalized").val());
var lower_limit = new Date();
lower_limit.setFullYear(lower_limit.getFullYear() - 1);
if(date < lower_limit) {
check = false;
} else {
check = true;
}
return this.optional(element) || check;
}, "{{ _('Please select a date within the last year.') }}");

$.validator.addMethod("dateInFuture", function(value, element)
{
let check;
let date = new Date($("#sample_date_normalized").val());
var upper_limit = new Date();
upper_limit.setMonth(upper_limit.getMonth() + 1);
if(date > upper_limit) {
check = false;
} else {
check = true;
}
return this.optional(element) || check;
}, "{{ _('Please select a date within the next 30 days.') }}");
$.validator.addMethod("dateInFuture", function(value, element)
{
let check;
let date = new Date($("#sample_date_normalized").val());
var upper_limit = new Date();
upper_limit.setMonth(upper_limit.getMonth() + 1);
if(date > upper_limit) {
check = false;
} else {
check = true;
}
return this.optional(element) || check;
}, "{{ _('Please select a date within the next 30 days.') }}");
{% endif %}

$("#sample_date").datepicker(datepicker_args)

Expand Down
Loading