Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Validation - user needs to complete at least one field of a table...

Avatar

Avatar
Validate 1
Level 1
ellis355
Level 1

Likes

2 likes

Total Posts

62 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 1
ellis355
Level 1

Likes

2 likes

Total Posts

62 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Applaud 5
Affirm 1
View profile
ellis355
Level 1

17-06-2015

Hi All

I have a table, which is populated by the user using dropdowns. I have some javascript which auto populates to the right of the users selection.

This all works fine however I now need to add some validation to check that the user has completed at least one field on one line.

The table is below

tableimpacts.JPG

So the validation (mandatory) needs to error unless at least one field is populated (in the dropdown section ie not 'Notes' or 'Date')

The pdf can be found here:

Dropbox - 207 For Forum.pdf

Any suggestions on the best method / cleanest code to make this happen?

Cheers

Ellis

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
jasotastic81
Level 4

19-06-2015

I suggest a Boolean called complete initialized to false, then loop through the fields in the right column (3 months) and if the field is not null, set the bool to true. Then check the bool and if it's true, you know at least one thing was filled in.


var complete = false;


//since you named all of the cells individually, we just have to look through each one.


if (!FinanceImpact7.isNull) complete = true;


if (!HealthSafetyImpact7.isNull) complete = true;


//etc...


if (!ReputationSatekholders7.isNull) complete = true;


if (complete) {


  //do whatever you would if it's complete


}


else {


  //do whatever you would do if it is NOT complete


}