Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
formapi max character
rodigz
Hi,
I want to use form api to validate the maximum character in DCT.
Find more posts tagged with
Comments
Michael
Hi
I presume you want to enforce a number of characters for a particular field.
For text and browser items you can use the maxlength attribute.
For textarea you could use something like:
var string = myItem.getValue();
if (string.length > 200)
{
myItem.setValid(false);
alert("You have entered " + string.length + " characters, you can enter a maximum of ......");
}
else
{
myItem.setValid(true);
}
Hope this helps, if not you might want to provide a few more details
Cheers
Michael
rodigz
Hi Michaeil,
Here's the script..It's not working
<item name="temp">
<label>Temperature</label>
<textarea cols="40" rows="5" wrap="virtual"/>
</item>
<script><![CDATA[
IWDatacapture.setHighlightMode(true);
IWEventRegistry.addItemHandler("/temp", "onItemChange", length);
function length(item) {
var string = myitem.getValue();
if (string.length > 200)
{
myItem.setValid(false);
alert("You have entered " + string.length + " characters, you can enter a maximum of ......");
}
else
{
myItem.setValid(true);
}
}
]]></script>
</ruleset>
</data-capture-requirements>
thanks!
Michael
Your function "length" accepts a parameter called "item". You then deal with an undefinted item called "myitem".
rodigz
thanks! it works now.
another question..
I want to call my js somewhere.
I defined the whole path but it's not working.
<script location="template-type" src="/iwmnt/default/main/GlobalSources/AutoPartsAndAccessoriesTest/WORKAREA/development/templatedata/Includes/maxcharacter.js" />
thanks!
Adam Stoller
If you're using location="template-type", then I believe you want src="../../Includes/maxcharacter.js" (not sure if relative paths work here though, haven't tested it myself).
--fish
(Interwoven Senior Technical Consultant)