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)
onSaveValid
infoForDj
Hi,
I have a javascript function which does validations on a browse field. This function is called on the event,"onSaveValid". The problem is it does all the validations, shows "done saving" in the status bar but then hangs, that is it does not prompt the user to save the DCR. Do I have to add extra code to make it work or do I need to do something different?
Thanks,
Dhruv
Find more posts tagged with
Comments
Adam Stoller
Does your function return true ?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
infoForDj
Hi,
It does return true.
Here is the code :
function setRegexForCommunicateSection()
{
regex = /(serviceHub|solutionHub)/;
activeContainers = IWDatacapture.getItem("/serviceLanding/servicesSolutionHubPageDCR").getChildren();
var result = browsePathRegex(activeContainers, regex, "true");
if(result == "true"){
return true;
}
else {
return false;
}
}
IWEventRegistry.addFormHandler("onSaveValid", setRegexForCommunicateSection);
Code for Javascript function browsePath Regex :
function browsePathRegex(activeContainers, regex, isReplicant){
if(isReplicant == "true"){
for(i=0;i<activeContainers.length;i++)
{
var str = IWDatacapture.getItem(eval(activeContainers[ i ]).getName()).getValue();
if(!regex.test(str))
{
alert("Incorrect value entered for "+eval(activeContainers[ i ]).getName());
IWDatacapture.getItem(eval(activeContainers[ i ]).getName()).setValue("");
return false;
}
else
{
return true;
}
}
}
else {
var str = IWDatacapture.getItem(activeContainers.getName()).getValue();
if(!regex.test(str))
{
alert("Incorrect value entered for "+activeContainers.getName());
IWDatacapture.getItem(activeContainers.getName()).setValue("");
return false;
}
else
{
return true;
}
}
}
Please help us in saving the DCR as this code returns true and then does nothing.
Adam Stoller
if(isReplicant == "true"){
for(i=0;i<activeContainers.length;i++) {
var str = IWDatacapture.getItem(eval(activeContainers
).getName()).getValue();
if(!regex.test(str)) {
alert("Incorrect value entered for "+eval(activeContainers
).getName());
IWDatacapture.getItem(eval(activeContainers
).getName()).setValue("");
return false;
}
else {
return true;
}
}
}
Can you explain in more detail what this code
should
be doing? If you
eval
activeContainers
what are you hoping to achieve? What
is
the value of
activeContainers
(I'd suggest putting some alerts into the code to verify
before
this line of code - as I don't think this is doing what you think it is).
Also - I don't think that
regex.test(str)
is necessarilly correct - wouldn't it be something more like
str.match(regex)
? (my ability to interpret javascript in my head is not anywhere near my ability to do so with Perl - sorry)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com