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.
SOLVED

Restrict Number Value Range

Avatar

Level 2

I am attempting to build a form with numeric fields that are supposed to limit the choices the user can enter.  Here are the choices:

  • null (empty)
  • 1
  • 2
  • 3
  • 4

The field should not allow the user to enter a 5 or above.  After the fields are all completed, I have a calculation at the end that averages all the data.

I tried to use a drop-down list, but that is formatted as text, and the calculation at the end of the form does not recognize the characters.

Please Help!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Take a look at the attached. It calculates an average for two drop-down list and two numeric fields, restricting values <= 4.

Steve

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

Take a look at the attached. It calculates an average for two drop-down list and two numeric fields, restricting values <= 4.

Steve

Avatar

Level 10

Sorry Steve, a lot of head scratching to get a regular expression test to work.

var vPattern = /[0,1,2,3,4]/;
var result = vPattern.test(xfa.event.newText);

if (result == false)
{
    xfa.host.resetData("xfa.form.form1.page1.NumericField4");
}

Niall

Avatar

Level 2

Thank you, Naiall

I'm a bit of a noob, so I'm not sure how to plug in the expression you wrote (below).

Could you walk me through how I would enter your suggestion?

Thank you!

Avatar

Level 2

Steve, your attachment was not attached. Could you re-send?

Avatar

Level 10

Hi,

You have to log onto the forums to see the attachments / uploads. They are not available through email notifications.

The script is in the example.

Niall

Avatar

Level 2

Sorry, I guess I should of thought of that.

As I stated before, kind of a noob....

Robert Gallagher

Safety/Env. Officer, PHS

206-766-7040

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] ----