Change the border of the field only when the condition satisfies

abhinandanparhi
Kilo Expert

Hi Community,

I want to throw an error for less than 3 characters in a string field but to make the field accept the value and change only the border of the field to green color if it is more than 3.The border-color scenario is throwing an error in compiler level only. I am using the following script :- 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}

if (newValue.length < 4) {
g_form.clearValue('u_username');
g_form.showFieldMsg('u_username','Username must be atleast 3 characters','error');

}
else

g_form.getControl('u_username').style.border-color=#2ecc71; // compiler is throwing error in this case only.

Kindly help me in this scenario.

 

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

(edited, sorry, had the wrong variable name)

Try this: I usually just set the value for style. 

g_form.getControl('u_username').style='border-color: #2ecc71;';

Hope this helps!

If this was helpful or correct, please be kind and click appropriately!

Michael Jones - Proud member of the CloudPires Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

4 REPLIES 4

Willem
Giga Sage
Giga Sage

Can you check if Isolate script is set to False? If it is set to true, might cause the error.

You can easily check by assing the Isolate script column to your list:

find_real_file.png

Sudhanshu Talw1
Tera Guru

As you are manipulating the DOM, check if isolate script should be set to false.

 

Thanks

Sudhanshu

Michael Jones -
Giga Sage

(edited, sorry, had the wrong variable name)

Try this: I usually just set the value for style. 

g_form.getControl('u_username').style='border-color: #2ecc71;';

Hope this helps!

If this was helpful or correct, please be kind and click appropriately!

Michael Jones - Proud member of the CloudPires Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Thanks Michael. This worked Perfectly.