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
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:
Any suggestions on the best method / cleanest code to make this happen?
Cheers
Ellis
Views
Replies
Total Likes
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
}
Views
Replies
Total Likes