Expand my Community achievements bar.

FormCalc script not captured in addInstance

Avatar

Former Community Member
Hi I'm a newbie trying to develop a form so any help would be GREATLY appreciated!



I wrote FormCalc code to validate a text field (empNum) within a subform to ensure that the user must enter a value of 0 or between 100000-199999. If they enter a value outside of this range an error message pops up.



I chose a text field versus a numeric field since the numeric field automatically inserts a "," for six digit numbers.



Several problems:



1. How can I ensure that the user only enters a numeric value and not a text or null value? Right now if the user enters text or a null value into empNum, the value is accepted and the user is allowed to submit the form.



2. When I click my addRow button it adds another instance of empNum but doesn't capture the FormCalc validation code for the empNum field. How can I ensure that every time the addRow button is clicked the validation code is included in the empNum field?



Thanks!
3 Replies

Avatar

Former Community Member
I'll address the original problem of it inserting a comma in the number - try using a display pattern of "999999", that should let you have the six digit number without a comma in it.



--

SteveX

Adobe Systems

Avatar

Level 5
Here is what you can do...

You can use the Numeric Field and then set it Display Pattern as "zzzzz9" and then use the following FormCalc code in 'exit' event.



This logic will works even with add instance....may be you need to tweak the messages a little bit.



if (HasValue($)) then

if (($.rawValue == 0) or (($.rawValue >= 100000) and ($.rawValue <= 199999))) then

//value accepted

$.rawValue = $.rawValue

else

xfa.host.messageBox("Please check the number. 0 or a value between 100000 - 199999 is accepted.")

//$.rawValue = ""

xfa.host.setFocus($.somExpression)

endif

else

xfa.host.messageBox("0 or a value between 100000 - 199999 is required for Emplyee Number")

xfa.host.setFocus($.somExpression)

endif



Hope this helps. Let me know how that works.



Good luck,

SekharN,

www.lawson.com

Avatar

Former Community Member
I have the same problem with code written in java script. The validation code written in the exit event of the drop down list does not get copied when a new instance is created.



Please help, this is driving me crazy.