Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

this.rawValue.length ???

Avatar

Former Community Member
From what i've read, this is supposed to show the length of the field data..



however it does not.. Can someone please tell me the correct code to determine the length of a field's value?



I have added app.alert(this.rawValue.length)to the exit event of a field & added a value to the field & exited but nothing happened.



Thank you..
4 Replies

Avatar

Former Community Member
That code looks correct. Do you have JavaScript selected rather than FormCalc? Did you tab out of the field rather than select somewhere else with the mouse?

Avatar

Level 6
That code will work for a text field, but not a numeric field. For a text field, the rawValue is a JavaScript String object, which has a length property. That is unless the field is empty, in which case it contains null, which you should test for in your code. A numeric field returns an integer or a float, depending on how you've got it configured.

Avatar

Former Community Member
Are you opposed to FormCalc for any reason? How about:



$host.messageBox(Len(TextField1))



Works with both text and numeric fields.
Here's an example.

Avatar

Former Community Member
Thank you for your replies - I use javascript because that's what i'm used to using(from AcroForm days) for calculations / validations.. even though things do not work as i had hoped..



That the code will work for a text field & not numeric field: that's probably the reason, .. Yes.. I tried now.. i guess checking for a value not to be null is the best solution (which will work for both types of fields)