Could the Mandatory status created when the user do somethi

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

Could the Mandatory status created when the user do somethi

#1

Postby t4nu » Mon Feb 29, 2016 9:11 am

Hi,
If I have 3 fields and the status mandatory of the field is defined by certain user input.
What I mean is something like this:
I have Field1, Field2, Field3. The status of Field1 is mandatory and the status mandatory of the Field2 and Field3 are defined by what the user entered in Field1.
For e.g. if the user enter N/A in the Field1 then Field2 and Field3 become not mandatory but other than that Field2 and Field3 are mandatory.

Is that possible to do that? If so any example that I can see?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Mon Feb 29, 2016 9:56 am

You can dynamically set a field mandatory. To make this work in your example you need to click the Immediate Validation option for the Field1 Field Control. Then when a value is entered for this field the On Change event will run on the server.

Your On Change event will look something like this:

Code: Select all

if (fields.Field1.value == "xxxx")
{
  fields.Field2.fieldControl.mandatory = true;
  fields.Field3.fieldControl.mandatory = true;
}
else
{
  fields.Field2.fieldControl.mandatory = false;
  fields.Field3.fieldControl.mandatory = false;
}
This works by running a server-side event so can cause a slight delay for the user - you should test to see if this is acceptable.

Another approach is to check all the input on the server after it's been entered and issue any messages you need to. But then of course the user can't immediately see which fields are mandatory.
0 x

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

#3

Postby t4nu » Mon Feb 29, 2016 10:02 am

Thank you very much. I will try it.
Hope it is run as I expected.
Jon wrote:You can dynamically set a field mandatory. To make this work in your example you need to click the Immediate Validation option for the Field1 Field Control. Then when a value is entered for this field the On Change event will run on the server.

Your On Change event will look something like this:

Code: Select all

if (fields.Field1.value == "xxxx")
{
  fields.Field2.fieldControl.mandatory = true;
  fields.Field3.fieldControl.mandatory = true;
}
else
{
  fields.Field2.fieldControl.mandatory = false;
  fields.Field3.fieldControl.mandatory = false;
}
This works by running a server-side event so can cause a slight delay for the user - you should test to see if this is acceptable.

Another approach is to check all the input on the server after it's been entered and issue any messages you need to. But then of course the user can't immediately see which fields are mandatory.
0 x


Who is online

Users browsing this forum: No registered users and 22 guests