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

How to stop Java Script Code applying to every text entry

  • March 3, 2022
  • 4 replies
  • 48 views

Forum|alt.badge.img+4

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!

4 replies

Aanurag_QC
QPN Level 5 ●●●●●
Forum|alt.badge.img+31

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


Forum|alt.badge.img+4

Only on that particular question.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • March 4, 2022

Change

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


Forum|alt.badge.img+4

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.