I'm using an HTTP button to check fields on a form before submitting. Can anyone help?
I need JavaScript to tell it to:
Check the total in the description of work table and make sure it’s 100%--return an error if it’s not
Check the other mandatory fields and return an error if they aren’t completed – it’s an XML submit button in LiveCycle so it is currently doing that
Give a “success” message when everything is completed
DO NOT generate an email when everything is OK – just the success message.
Buttons on my form – the one I’m needing help with is check form before submitting
This is how the button is currently set up.
This is the table where I need the total percentage of time to be checked to be sure it’s 100%.
This shows the hierarchy and naming of the table.
Formula for total in table.
Views
Replies
Total Likes
I tried this for checking the mandatory fields, but I have a syntax error in line 8 and I don't know what it is.
function validateForm ()
{
var bMsg = false;
//loop through all pages in the form
for (var nPage=0; nPage<xfa.host.numPages; nPage++)
{
//loop through fields in the page
var oFields = xfa.layout.pageContent(nPage, “field”);
var nNodes = oFields.length;
for (var n=); n<nNodes; N++)
{
//if the field is required
if (oFields.item(n).validate.nullText==”error”)
{
restoreField(oFields.item(n));
if (oFields.item(n).rawValue==”” ||
oFields.item(n).rawValue==null)
{
highlightField(oFields.item(n));
bMsg = true;
}
}
}
}
if (bMsg)
{
xfa.hostmessageBox (“At least one required field is empty”);
return false;
}
return true:
}
function restoreField(fld)
{
var oFld = xfa.resolveNode(fld);
var uiFld.ui.resolveNode(“#textEdit#);
if (uiFld == null)
uiFld = oFld.ui.resolveNode(“#choiceList”);
if (uiFld != null) // only handles text field and list box
{
//restore the original white color
uiFld.border.presence = “visible”;
uiFld.border.fill.color.value = “255, 255, 255”;
}
}
function highlightField (fld)
{
var oFld = xfa.resolveNode(fld);
var uiFld = oFld.ui.resolveNode(“#textEdit”);
if (uiFld == null)
uiFld = oFld.ui.resolveNode(“#choiceList”);
if (uiFld != null) //only handles text field and list box
{
//restore the original white color
uiFld.border.presence = “visible”;
uiFld.border.fill.color.value = “255,255,128”;
}
}
Views
Replies
Total Likes
Hi,
Might be just the forum editor, but this quotes used seem to be the fancy ones like Word uses. Also this line is mucked up;
for (var n=); n<nNodes; N++)
I presume it should be, something like;
for (var n=0; n<nNodes; N++)
Maybe a link to the actual form would be easier.
Regards
Bruce
Views
Replies
Total Likes
Thanks. The quotes are "" in LiveCycle. I've been working with the code in a Word document, so that's why they pasted over as quotation marks.
My IT environment won't allow me to post the form where others can access it. :-/
The line with the syntax error is:
var oFields = xfa.layout.pageContent(nPage, “field”);
Views
Replies
Total Likes
Hi, I you retype the quotes in LiveCycle Designer then you will get rid of the MS Word quotes and then syntax wise that line will be fine.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies