JavaScript Help

Apr 05, 2019

Hello, 

I wanted to limit my character limit for a SL360 text answer.  I used the JavaScript below (thanks Google!), but I can't figure out how to make the placeholder text show "Type Text Here."  

Any JavaScript gurus out there who can help me???  Here's the link to the course slide and the code below:

https://360.articulate.com/review/content/9bea84d4-23ff-4f3c-b711-4cf89a43d0e1/review

 

var fields = ["Cause1", "Cause2", "Cause3", "Cause4", "Cause5", "Symptom1", "Symptom2", "Symptom3", "Symptom4", "Symptom5"];

(function setMaxChars(fields) {

    fields.forEach(function (field, field_index) {

         $('[placeholder=' + field + ']').attr('id',field);        

         $("#Cause1").attr("maxlength","15");

         $("#Cause2").attr("maxlength","15");

         $("#Cause3").attr("maxlength","15");

         $("#Cause4").attr("maxlength","15");

         $("#Cause5").attr("maxlength","15");

         $("#Symptom1").attr("maxlength","15");

         $("#Symptom2").attr("maxlength","15");

         $("#Symptom3").attr("maxlength","15");

         $("#Symptom4").attr("maxlength","15");

         $("#Symptom5").attr("maxlength","15");

         $('[placeholder=' + field + ']').attr('placeholder', '');

 });

})(fields);

1 Reply
Steve Gannon

Hi Elizabeth,

I would need to see the relevant portion of your .story file to be sure, but I think you should be able to precede the JavaScript code you listed above by assigning an initial value to each of the variables in your "fields" array like this:

var Cause1 = "Type Text Here."

var Cause2 = "Type Text here."

var Cause3 = "Type Text here."

...and so on.

This discussion is closed. You can start a new discussion or contact Articulate Support.