Skip to main content
Participating Frequently
October 10, 2018
Question

Replace font with based on character count with javascript

  • October 10, 2018
  • 1 reply
  • 1580 views

Is this possible?

I basically want to use a different font, if the length of character is over a certain count.

I would need the javascript code to do the following:

If the length of the typed text in the form is greater that 30 characters, I want to use Arial Narrow, if under, then just use Arial.  The font would always need to be 11 pt in all cases.

This topic has been closed for replies.

1 reply

Participating Frequently
October 12, 2018

After googling around (still not knowing what I'm doing), I would think it would be something like this going into Custom Calculation Scripts, but it's not working for me:

if (this.rawValue.length < 30) {

    textSize = "11";

    textFont = "Arial";

}

else {

    textSize = "11";

    textFont = "Arial Narrow";

}

any ideas what I'm doing wrom?

Bernd Alheit
Community Expert
Community Expert
October 13, 2018

Look for errors in the console.

Participating Frequently
October 15, 2018

I haven't used that before - I see if I can figure it out. Really not proficient in javascript. I've done plenty coding with VBA, which looks kinda similar...