How to stop Java Script Code applying to every text entry | XM Community
Skip to main content

Java Script Screenshot.PNGHello!
I have a question (Q7) where I am asking respondents what their phone number is, and I want the numbers to be inputted in this form: 111-111-1111, where the dashes are automatic once they start to enter their number. Above is the code I have in that question. It works, but it is applying to every single text entry question, not just Q7. How do I get it to only apply to Q7?
Thanks!

Are you applying JS only on that particular question or adding it in the header to apply in the entire survey?


Only on that particular question.


Change

jQuery(".InputText")
to
jQuery("#"+this.questionId+" .InputText")
.


Hi Tom, thanks for your answer! When I do that, the dashes no longer appear for any of the questions, including Q7, which is the question it is coded for.


Leave a Reply