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

javascript for blank field validation on repeating subforms

Avatar

Avatar
Validate 10
Level 2
Jodi1725
Level 2

Likes

6 likes

Total Posts

113 posts

Correct Reply

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

Avatar
Validate 10
Level 2
Jodi1725
Level 2

Likes

6 likes

Total Posts

113 posts

Correct Reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
Jodi1725
Level 2

29-01-2018

Hello All!

I have a form with repeating subforms.  You click a button and a second(or third)instance of a subform is generated.

I need to create javascript on a print button that verifies certain fields on each subform is filled in (name address, etc)

I found this doc Loop Through Subform Instances  that shows me how to loop thorough the subform and I can make it work for 1 field, but i have more than one field to validate.


Any idea how to write the javascript that can run through multiple fields on multiple subforms?

Thanks in advance!!!

Jodi

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 10
Level 2
Jodi1725
Level 2

Likes

6 likes

Total Posts

113 posts

Correct Reply

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

Avatar
Validate 10
Level 2
Jodi1725
Level 2

Likes

6 likes

Total Posts

113 posts

Correct Reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
Jodi1725
Level 2

31-01-2018

I used this code

expenseReport.#subform[0].validate2::click – (JavaScript, client) 
var vItems = expenses.expense.all; 
for(i=0; i<vItems.length; i++) 

    if (vItems.item(i).description.rawValue == null) 
    { 
        xfa.host.messageBox("Missing description field"); 
        break; 
    } 
}

I had to put the vItems.item(i) for each of the fields.  when I did that it worked!

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

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

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

31-01-2018

Thats great. I am going to save that code, i might be able to put it to use.

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

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

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

29-01-2018

What about just repeating the logic code for the next field? When run, after the first field is verified, the script will just keep running to the next logic code.

You could just use the OR operator to test mulitple fields so it is like 'if this or this or this is null, then do something'