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)
formAPI + Image path validation
sachin_sharma78
hi friends,
i know its a silly question but this peice of code is not running though i have run it many a times in past. function is not called by IWEventRegistry.addItemHandler.
<script language="java-script">
<![CDATA[
var root = '/templatedata';
IWEventRegistry.addItemHandler("/root/picture","onItemChange",pathset);
function pathset(item){
if(item.getValue().substring(0,root.length)==root){
item.setValue(item.getValue().substring(root.length));
IWDataCapture.refresh();
}
}
]]>
</script>
rgds,
sachin
Find more posts tagged with
Comments
Bjorn
Sachin -
What do you want the pathset function to do?
Bjorn
sachin_sharma78
Hi Bjorn,
I want this function to remove " templatedata " from imagepath.
Bjorn
I am not sure if I understand the whole picture, but if all you need to do is remove a certain string value from another string value, then either replace the value using indexes and substrings or use a javascript regular expression.
I haven't tested this code, but it could get you started.
<script>
//literally create regex object
// true if "/templatedata" is at beginning
rootRegEx = /^\/templatedata/;
IWEventRegistry.addItemHandler("/root/picture","onItemChange",pathset);
function pathset(item){
var itemValue = item.getValue().;
// test method returns boolean if there is match
if (rootRegEx.test(itemValue){
// replace method (of String object) uses a regex to replace
var itemValue = itemValue.replace(rootRegEx,"");
item.setValue(itemValue);
}
}
</script>