Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

formcalc equivalent of javascript

Avatar

Former Community Member

Hello,

I am using the following little snippet, courtesy of radzmar. It works just fine as it is, but I am attempting to convert it to its formcalc equivalent, but can't seem to get it to work. Specifically, the syntax for the part in red is what I need.

if (xfa.event.newText.match(/[^0-9]/))  

xfa.event.change = "";

On a related note, can anyone recommend a book or guide that would have just this sort of information for those just learning to use LiveCycle Designer? The built in reference has very basic syntax examples but nothing that seems to help from that point on. For example, the section on "newText"  says nothing about which properties can be used with it, such as in this case, "match". 

Thanks.

Harry.

4 Replies

Avatar

Level 10

You can use a FormCalc function to do so.

Put this into the change:event of the field.

if (Within(xfa.event.change, 0, 9) ne 1) then

     xfa.event.change = ""

endif

Avatar

Former Community Member

Thanks radzmar. That worked like a charm.

How would I add the backspace and delete keys to be allowed along with the numerals?

Also, I am now doing the processing of the data that is input in the text field in the exit event of the field.

Basically what it does is to take a number upto 5 digits and if a checkbox is on, then the number is formatted as a decimal time, and if it is not on, then the number is formatted in aa:bb format.

Thus while in decimal format, a time such as 56.85 hours is acceptable, in the standard notation, 56:85 hours is not.

What I want to do is if the checkbox is off (and so standard aa:bb notation is used, if the last two digits are >  59, the field is nulled and the cursor stays in the field until I either enter a correct number or else exit to another field.

What I am asking is, can this processing be done in the change event of the field? If so, would I do it within the if statement you used in your reply above? I tried it outside the if statement, but it did not work.

Thanks again, for you help. I appreciate it!

Harry.

Avatar

Former Community Member

Upon further thought, I'm thinking the following would be the way to do it:

if (Within(xfa.event.change, 0, 9) ne 1) then

     xfa.event.change = ""

//  within this if statement, check status of checkbox, and if true, then

//  if last two digits entered are collectively greater than 59, then

//  null the field and start over

// once correct data is entered, go on to exit event processing

endif

Avatar

Level 10

Hi Harry, here are a couple of links to FormCalc reference guides if you don't have them:

8.2: http://help.adobe.com/en_US/livecycle/8.2/FormCalc.pdf

9.0: http://help.adobe.com/en_US/livecycle/9.0/FormCalc.pdf

Old but good introduction to scripting in LiveCycle Designer:

http://help.adobe.com/en_US/livecycle/9.0/lcdesigner_scripting_reference.pdf

And if you are looking for more general info on building forms, J.P. Terry's book Creating Dynamic Forms With Adobe LiveCycle Designer is great.

http://www.amazon.com/Creating-Dynamic-Forms-LiveCycle-Designer/dp/0321509870