You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure if this is useful? I wondered about you having a space for add-ons, or snippets - which is really what this is. I imagine different users create bits of code - that work for them - and could be useful for others. You could list - but not support or guarantee.
Anyhow...
This uses date format yyyy-mm-dd or,
yyyy-mm-dd hh:mm
messages = {
... as per,
mustPostDate : 'Depart <i>after</i> Arrival'
},
Validator = {
// postDate check; end date must be after start date
postDate : function( tmp, self ) {
var startDate = self.form.querySelector('input[name="'+ tmp.arg +'"]').value;
if (startDate.length>'0') { // startDate must be set
// work on start date
if (/ /g.test(startDate)) { // with time: "yyy-mm-dd HH:MM" - 24hr clock
var startRaw = startDate.split(' ')[0].split('-');
var timeRaw = startDate.split(' ')[1].split(':');
var hours = timeRaw[0];
var mins = timeRaw[1]; }
else { var startRaw = startDate.split('-'); // plain date: "yyy-mm-dd"
var hours = '0'; var mins = '0'; }
// Date.UTC(yy,mm,dd,hh,mm,ss); = milliseconds
var startStamp = Date.UTC(startRaw[0],startRaw[1]-1,startRaw[2],hours,mins,0)/1000;
// work on end date
if (/ /g.test(tmp.val)) { // with time: "yyy-mm-dd HH:MM" - 24hr clock
var endRaw = tmp.val.split(' ')[0].split('-');
var timeRaw = tmp.val.split(' ')[1].split(':');
var hours = timeRaw[0];
var mins = timeRaw[1]; }
else { var endRaw = tmp.val.split('-'); // plain date: "yyy-mm-dd"
var hours = '0'; var mins = '0'; }
var endStamp = Date.UTC(endRaw[0],endRaw[1]-1,endRaw[2],hours,mins,0)/1000;
return endStamp >= startStamp || messages.mustPostDate; }
else return; // startDate not yet set
},
// etc...
}; // END Validator =
I think that's it.
The text was updated successfully, but these errors were encountered:
I am not sure if this is useful? I wondered about you having a space for add-ons, or snippets - which is really what this is. I imagine different users create bits of code - that work for them - and could be useful for others. You could list - but not support or guarantee.
Anyhow...
This uses date format yyyy-mm-dd or,
yyyy-mm-dd hh:mm
I think that's it.
The text was updated successfully, but these errors were encountered: