How do i disable my date text field when I'm using date picker to select date? Currently I'm getting multiple date formats in our data although I've setup date picker. I prefer to disable the manual input so folks will use date picker instead. This is the custom code I have setup for my date field. Any suggestions on what is missing? I can still manually enter the dates although it is readonly.
Qualtrics.SurveyEngine.addOnload(function()
{
var textInputs = this.questionContainer.querySelectorAll('input[type="text"]');
if (typeof textInputs[0] !== 'undefined') {
textInputs[0].type = 'date';
}});
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery("[id='QR~QID10~TEXT']").attr("readonly",true);
});
Qualtrics.SurveyEngine.addOnUnload(function()
{ /*Place your JavaScript here to run when the page is unloaded*/
});
Solved
Setting date field as read only while using date picker
Best answer by mingchiat
Thanks Jeremy for your suggestions. Indeed Flatpickr is the better solution and truly versatile.
By adding this additional script in OnLoad, it works.
jQuery("#"+this.questionId+" .InputText").flatpickr({
dateFormat: "m/d/Y"
});
Thank you so much!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.