Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Help with LEN syntax

Avatar

Former Community Member
Maybe it's the post-Christmas hangover, but for the life of me I can't figure out the proper syntax for a LEN statement in Javascript. I'm ultimately trying to build in some validation logic, but right now am just trying to display a message box if the length of the StockNoText field is 8 characters. Here is my current Javascript code:



If(Len(StockNoValue.rawValue) == 8)

{xfa.host.messageBox("The length is 8");}



Any help that you can provide with correcting this would be most appreciated!



Paul
3 Replies

Avatar

Former Community Member
I guess the 8 and the parentheses were interpreted as an emoticon, but my "IF" statement should read "if the length of the value entered in the StockNoValue field is 8".



Paul

Avatar

Former Community Member
After more research (and hair pulling), in the Javascript world the correct syntax for the above example is "StockNoText.rawValue.length". Note that "length" does not automatically appear in the list of values as you're building the string, so you'll have to accept the LoadXML entry, then backspace over it and replace with "length".

Avatar

Former Community Member
Paul,



As you've seen, length is the property you want, it is part of standard JavaScript and not part of the Adobe DOM, that's why it doesn't appear in the code assist :(



Len() is a method in the FormCalc scripting language, that's why you were having trouble when trying to use it in JavaScript.



Chris

Adobe Enterprise Developer Support