Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Form validation question

Avatar

Former Community Member

If I find a problem in the data entered in a form, can I cause a specific field to be highlighted after routing the user back to the field?  And can I cause a popup message warning the user of the specificly invalid field?

Newbie needs help,

Jerry

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The attached produces the following results to highlight various techniques for getting a user's attention. While the validations are relative to each field you can point the scripts at any field. Note, the 'Last Name' edit throws up the message box and sets focus back to the field if the field is null. Be VERY careful using 'xfa.host.setfocus()'. You can easily find yourself creating a form where user's get stuck...really stuck.

p1.png

Steve

View solution in original post

4 Replies

Avatar

Correct answer by
Former Community Member

The attached produces the following results to highlight various techniques for getting a user's attention. While the validations are relative to each field you can point the scripts at any field. Note, the 'Last Name' edit throws up the message box and sets focus back to the field if the field is null. Be VERY careful using 'xfa.host.setfocus()'. You can easily find yourself creating a form where user's get stuck...really stuck.

p1.png

Steve

Avatar

Level 3

Wonderful Example!

I've tried to implement the example unfortunatally I cannot make it work.

Under what event the code should placed? I've placed it in the Exit event is that right?

Deos the form need to be Dynamic?

I've included the form. The field that I want to check is called Requested By

Would you be kind to have a look?

Avatar

Former Community Member

Sorry for the late reply.  We just finished a four day weekend.

I made the form dynamic and I used the click event.  If this is still an open issue, I'll be happy to expand on that.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----