peter_cawdron_p
Giga Expert
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 09-22-2019 06:34 PM
US date formats are a pain in the @$$ for anyone using European date formats (like us here in Australia).
As an example...10/11 for a European is the 10th of Nov and is treated as such by the browser. Pass that to the server though and it magically becomes the 11th of October (seriously, that is not cool). While 13/11 will be understood by both the browser and the server as 13th of November. Yeah... fun times...
If you are looking to validate European dates, don't use script includes or you'll run into these kind of inconsistencies, instead, handle dates entirely on the client in the browser and you'll save yourself a bunch of headaches.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;
var epochStart = getDateFromFormat(g_form.getValue('start_date'), g_user_date_time_format);
var epochEnd = getDateFromFormat(g_form.getValue('end_date'), g_user_date_time_format);
var epochNow = new Date().getTime();
if(epochStart > epochEnd && epochEnd !=0){
g_form.showFieldMsg('start_date', "Your planned start date should not occur after the planned end date",'error');
}
if(epochStart < epochNow){
g_form.showFieldMsg('start_date', "Your planned start date should not occur before now",'error');
}
}
Labels: