I'm asking for my respondents date of birth. Therefore I'm using a text entry question for which I set response requirements - add validation - content type - date format - dd/mm/yyyy. I like to have it this way that the textbox is already formatted this way --/--/---- --> so the participants don't need to type the / / themselves. Is it possible to pre-format the text-entry? Thanks in advance!
Solved
Pre-format text entry to date
Best answer by Tom_1842
Hmm it is working for me. Make sure that cleave is loaded in the survey's header:
<script src="https://cdn.jsdelivr.net/npm/cleave.js@1/dist/cleave.min.js"></script>
And then add the below to the OnReady section of the question's JavaScript:
new Cleave(jQuery("#"+this.questionId+" .InputText").get(0), {
date: true,
delimiter: '/',
datePattern: ['Y', 'm', 'd']
});
If you are using Simple layout, you will also need to add jQuery to the survey's header:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cleave.js@1/dist/cleave.min.js"></script>
And then add the below to the OnReady section of the question's JavaScript:
new Cleave(jQuery("#question-"+this.questionId+" .text-input").get(0), {
date: true,
delimiter: '/',
datePattern: ['Y', 'm', 'd']
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.