Ever have to use Validate to ensure that all fields in a form are filled in before it can be submitted? I have a form with a table in it, and if a user filled in any value on that table, I have to ensure that all five values in that row are filled in before the form can be submitted. I have found an easy way to do this.
I add a hidden field for each field in my table. The computed value for each of those fields is set to 0 if the field is blank, or 1 if it is not blank. Then I add a 'total' field that sums up the values for each row of my table.
Then, my validate formula on my "Submit" button just has to do the following (with an entry for each row of my table):
FIELD SendTo := SendTo; FIELD Returned_date := Returned_date; @Command([ViewRefreshFields]); Validate := @If(Line1_total > 0 & Line1_total < 5; @Do(@Prompt ([OK];"Missing Information"; "Missing information for table row #1"); @Command([EditGotoField];"MFTran1"); @Return("")); . . . Line20_total > 0 & Line20_total < 5; @Do(@Prompt([OK];"Missing Information";"Missing information for table row #20"); @Command [EditGotoField];"MFTran20"); @Return(""));"OK"); @If(!@IsValid; @Return(""); Validate = "OK"; @Do(@SetField("SendTo"; "submit to name goes here"); @SetField ("Returned_date";@Today);
A hidden field for every field on the form? That verges on insane. Much easier to have a single field that does all the validation. You end up with all your validation code in one place, where it can easily be read. And to make it easier on the user, you can build a text array of all the errors they have and return that.
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Diane Marget. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.