Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

JavaScripting for check work button in LiveCycle Designer

akgrimes
Level 3
Level 3

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

1024732_pastedImage_13.png

This is how the button is currently set up.

1024733_pastedImage_15.png

This is the table where I need the total percentage of time to be checked to be sure it’s 100%.

1024734_pastedImage_17.png

This shows the hierarchy and naming of the table.

1024735_pastedImage_18.png

Formula for total in table.

1024736_pastedImage_19.png

4 Replies
akgrimes
Level 3
Level 3

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”;

}

}

_Bruce_Robertson
Level 10
Level 10

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

akgrimes
Level 3
Level 3

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”);

_Bruce_Robertson
Level 10
Level 10

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.