character limit on single line field

sarahkapasi
Giga Expert

We have a Service Catalog Item with a single line field variable which has character limit to 40 characters.

find_real_file.png

I would like to make it so the user can't 'Order Now' until 40 characters are in that field.

Thank you,

Sarah

1 ACCEPTED SOLUTION

Ty this:



function onSubmit() {


  var text = g_form.getValue("u_epic_device_haiku_canto");


  var length=text.length;


if(length <40)


{


  alert("Please enter full field");


  return false;


}}


View solution in original post

9 REPLIES 9

Check on Onchange script for that field.



var textBox = g_form.getValue("field_name").length;  


if(textBox <40)  


{  


  alert("Please enter full field");  


}


Ty this:



function onSubmit() {


  var text = g_form.getValue("u_epic_device_haiku_canto");


  var length=text.length;


if(length <40)


{


  alert("Please enter full field");


  return false;


}}


Thanks so much!   That worked!


I have a similar challenge but in this case it should only be possible to enter six numbers from 0 to 9. How shold the if-sentence look like in order to achieve that?

Best regards

xiaix
Tera Guru

Doesn't work.  This field never saves.

Very lame that this happens.  It's absurd that you can't set max_length, and that you'd need to rely on an onSubmit script to handle it.

So, I personally get the maxlength attribute set by manipulating the DOM via an SP widget:

I have a Single Line Text field named "upc" as a Catalog Item Variable.

 

find_real_file.png

find_real_file.png

find_real_file.png