Compare Dates
- KateřinaCísařová
- Posts: 2
- Joined: Tue Apr 20, 2021
Hi,
is there a way to compare date with today function?
I need to change status if user chooses date less than today.
Thank you very much.
K.
is there a way to compare date with today function?
I need to change status if user chooses date less than today.
Thank you very much.
K.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Kateřina,
Sorry for the delay, lots of SPAM being sent to the forum and it takes time to filter it out. For a more speedy reply, please, contact us at support@spform.com
As for comparing dates, here's how you can access field values and get them on change - https://spform.com/javascript-framework ... eld-values
For the default Date field, something like this would work:
Sorry for the delay, lots of SPAM being sent to the forum and it takes time to filter it out. For a more speedy reply, please, contact us at support@spform.com
As for comparing dates, here's how you can access field values and get them on change - https://spform.com/javascript-framework ... eld-values
For the default Date field, something like this would work:
Code: Select all
function compareDateToToday(date){
var q = new Date();
var m = q.getMonth();
var d = q.getDate();
var y = q.getFullYear();
var today = new Date(y,m,d);
if(today>date){
alert("Date is before today");
}
else if (today<date){
alert("Date is after today")
}
else{
alert("Date is today");
}
}
fd.field('Date').change(function(){
var date = new Date(fd.field('Date').value());
compareDateToToday(date);
});
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 12 guests