Hello!
I have 2 dates that will be entered by the user, a starting date and an ending date.
Currently, I am using flatpicker to set those up as month/year.
What I would like to do is to "compare" the dates, and indicate if the ending date is before the starting date.
I know that I can't do that in regular Qualtrics, so I did put together a little Javascript code to do that. I am a Javascript newbie, so please forgive my coding practice.
function dateproduce(x) {
const myArray1 = x.split(".")
var y1 = myArray1[1];
var m1 = myArray1[0]-1;
if(m1==-1) {
m1 = 12;
y1 = y1 - 1;
}
var dt1 = new Date(y1,m1);
return dt1;
}
var st = "1.2020";
let dta1 = dateproduce(st);
document.write(dta1);
var et = "1.2021";
let dta2 = dateproduce(et);
if(dta2 < dta1)
document.write("incorrect date");
else
document.write("correct date");
```
So essentially, I would like to put this in my question, but I don't know how to get the variable names, or how to display an error, if necessary.
Any help much appreciated.
Thanks,
Erin
Adding Javascript to dates
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
