Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Text item loosing maxlength constrain on setValue
cliffhanger
Hello everyone,
We are on TeamSite6.1 SP1 and OS Windows 2000. I have come across a bizzarre behavior of FormAPI function IWItem.setValue(). We have a DCT field of type text and its maxlength is 100. If the user types into the text field, then it limits user entry to the maxlength.
However, if I use fieldItem.setValue() I can set the value of the item to a string that is twice as much the maxlength. It seems like with setValue() the text field is loosing its maxlength constrain.
Has anyone encountered this issue??
Thanks
-cliffhanger
Find more posts tagged with
Comments
Migrateduser
Yes, and it's not strange behavior. Javascript basically doesn't care what the form limitations are. If you tell it to set a value, it will.
To limit the field to 100 characters, try doing so through Javascript before setting the value:
var str = "Something longer than 100 characters...";
item.setValue(str.substring(0,99));
Dave
Current Environment(s):
(1) TS 6.1 SP1 on W2K3
(2) TS 6.1 SP2 on W2K
(3) TS 6.1 on W2K
cliffhanger
This means we have to account for this limitation in our code. I expected FormAPI to enforce this rule because IWITEM is not a built-in Javascript object. Is this documented anywhere??
Thanks Dave!!
Migrateduser
How so? You're already using FormAPI, so it seems that you would need to add one (possibly two) lines to your existing code. I don't believe this quirk is documented through TS-specific channels, but I was actually doing something just like this within the past couple of days, but it was outside of Teamsite entirely -- on a site that does not have any content management implementation. I saw the same thing there with vanilla HTML and Javascript, so you're more likely to find something about it on the web.
In sum, I wouldn't blame IW for this at all, since this is pretty consistent with traditional Javascript and HTML.
Dave
Current Environment(s):
(1) TS 6.1 SP1 on W2K3
(2) TS 6.1 SP2 on W2K
(3) TS 6.1 on W2K