Character limit on multi line text variable

wiltonr
Giga Contributor

Does anyone know the character limit on the multi line text catalog variable?  

1 ACCEPTED SOLUTION

Hi Rhonda,



For variables there is no limit and allows you to as many lines you like.



Thanks!


View solution in original post

18 REPLIES 18

munney
Mega Contributor

Hey, not sure if this is still an issue, I was having the same issue today and was able to resolve this with the following onLoad catalog client script.



function onLoad() {


  //Type appropriate comment here, and begin script below


  var i = document.getElementById('element_id'); //variable name


  i.maxLength = '1050';


}



you can get the id by right clicking the variable in the form view, and choosing inspect and finding the id='IO ######################' text example below.



<textarea class="question_textarea_input cat_item_option" wrap="soft" id="IO:cfe90c11d57cd200585544e383220bc0" onchange="if (typeof(variableOnChange) == 'function') variableOnChange('IO:cfe90c11d57cd200585544e383220bc0')" name="IO:cfe90c11d57cd200585544e383220bc0" rows="5" maxlength="1050" style="height: 300px; overflow: hidden; word-wrap: break-word; resize: none;"></textarea>



Hope this helps!


Hi @munney 

 

Can you please help me onload if I mention this id not working.

Luis Nunez
Tera Expert

function onLoad() {


  try {


  //Use the 'onkeyup' event to check the 'isMaxLength' function


  //Get the control


  var control = g_form.getControl('YourVariable');


  //Set its onkeyup method


  control.onkeyup = isMaxLength;


  } catch(ex) {


  alert("Exception1: " + ex);


  }


}




function isMaxLength(){


  try {


  //Max Length 123 Characters


  var mLength=123;



  var control = g_form.getControl('YourVariable');


  //Compare the length


  if (control.value.length >= mLength){


  g_form.hideErrorBox('YourVariable');


  try {


  // message shown


  g_form.showErrorBox('YourVariable', 'You have reached the maximum character limit for this field.');


  } catch(e) {


  //showerrorbox or showfieldMsg would trigger an error, that is the reason why we catch the error without doing anything.


  }


  control.value = control.value.substring(0, mLength);


  }


  else{


  // hide the error when below 123 Characters


  g_form.hideErrorBox('u_sms_message');


  }


  }


  catch(ex) {


  alert("Exception2: " + ex);


  }


}


Hello Luis,


I have to implement the same for the Service Portal..getcontrol method won't work there.Is there any solution for this?




Thanks


saranya


Did you ever find a solution to this?  I need to restrict input on a Service Portal form to a specific number of characters.

Thanks
David