Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Removing spaces from text entries with javascipt (2016)

Explorer ,
Apr 18, 2016 Apr 18, 2016

Hello,

I'm hoping someone could help me with a script or even a regular to remove the blank spaces between words in the text entry boxes.  I found this thread from 3 years ago, but the code doesn't seem to work - I'm using Captivate 9:

Removing spaces from text from text entry box

At the time the solution posted was:

var objCP = document.Captivate; 

var jsTextEntry = objCP.cpEIGetValue('TextEntryBox1');  
var jsNoSpaces = jsTextEntry.replace(/ /g,'');

objCP.cpEISetValue('varNoSpaces', jsNoSpaces);

But again, this doesn't work for me. Any suggestions? Thanks.

Bill

239
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Apr 18, 2016 Apr 18, 2016

Never mind, I think I figured it out. For future reference, this seemed to work - changes the multi-word cpQuizInfoStudentName to OneWordName without spaces: 

var getName = window.cpAPIInterface.getVariableValue( "cpQuizInfoStudentName" );

  

var newName = getName.replace(/ /g,'');

      window.cpAPIInterface.setVariableValue('v_OneWordName', newName);

Translate
Explorer ,
Apr 18, 2016 Apr 18, 2016
LATEST

Never mind, I think I figured it out. For future reference, this seemed to work - changes the multi-word cpQuizInfoStudentName to OneWordName without spaces: 

var getName = window.cpAPIInterface.getVariableValue( "cpQuizInfoStudentName" );

  

var newName = getName.replace(/ /g,'');

      window.cpAPIInterface.setVariableValue('v_OneWordName', newName);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources