How to add a character limit on a record producer?

jewellaubert
Kilo Expert

I am trying to add validation on my record producer.  If a field's value is more than 6 characters, excluding symbols, show error message.  I was able to accomplish this with the form that the service desk uses but not the end user side.  Below is the code that I found online, can someone please assist?  

 

if (newValue.length > 6) {

g_form.setValue('u_account_number', 0);

g_form.showFieldMsg('u_account_number', 'You may not enter a more than 6 characters', 'error');

1 ACCEPTED SOLUTION

VigneshMC
Mega Sage

Try

if (newValue.length > 6) {

g_form.clearValue('u_account_number');

g_form.showFieldMsg('u_account_number', 'You may not enter a more than 6 characters', 'error');
}

View solution in original post

3 REPLIES 3

VigneshMC
Mega Sage

Try

if (newValue.length > 6) {

g_form.clearValue('u_account_number');

g_form.showFieldMsg('u_account_number', 'You may not enter a more than 6 characters', 'error');
}

Allen Andreas
Administrator
Administrator

Hi,

So what did you do for the form that works for fulfillers? What you pasted above?

Do you have this placed in an onChange client script and then have you chosen that variable as the field in which to enact itself upon?

Please share the full script from that onChange client script and include a screenshot as well of the whole thing if you can.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Brian Lancaster
Tera Sage

I just tried you code in my persona dev instance after I created this field and a record producer.  It seems to work fine for me.  I notice that you mentioned 6 char excluding symbols but just checking the length of a string would include all chars.  Is there more to you script that you are not sharing?