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.

Forcing a User to enter Data

Avatar

Former Community Member
I have a Designer 7 form where every field must be filled and the user must not go on to the next field until the current one is completed.



In Designer 5 the following 'OnExit' script would always set focus to the required field no matter what the user tried to do.



// Ensure that a Surveyor Name is entered.

if (SURVEYOR_NAME.Value == "")

{Form.MsgBox(0, "You must choose a (surveyor) 'Name'","Missing Information");

Form.GoToField(SURVEYOR_NAME, 1);}



In Designer 7 selecting the 'Value / Type / User Entered - Required' only produces a one-off message that the user can ignore. As a result I've tried using 'exit' script along the lines of:



// Ensure that an Action is entered.

if (Action1.rawValue == null)

{xfa.host.messageBox("Please select an appropriate action from the list provided.","Missing Information 1",0);

xfa.host.setFocus("Action1");}



Although this script will work when there is just one field on the form, when there several fields (all with similar script) the focus does not remain on the appropriate field. As this must be common requirement I'm sure that there is a simple solution out there somewhere - any help would be much appreciated.
4 Replies

Avatar

Level 1
jimmypham, the above link doesn't work anymore. Could you update?

Thanks!

Avatar

Former Community Member
what i recommend is using the key word 'this' to refer to the field it self.



so you'd have this to check if field == null then keep focus

this would go on the exit event.



if (this.rawValue==null)

{

xfa.host.messageBox("Please enter partner name!");

xfa.host.setFocus("this");

}



never had a problem with however many fields i have on page.

Avatar

Former Community Member
I am validating my form by each field. If I tab to another field without completing then it loops thru all the message boxes and it will not return to the setfocus field. It just loops and I have to terminate the program in order to break the looping...



What is causing this and how can I solve it?



thanks