Manage Learn to apply best practices and optimize your operations.

An easier way to use Validate

Ever have to use Validate to ensure that all fields in a form are filled in before it can be submitted? Here's an easy way to do it.

View member feedback to this tip.

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);

MEMBER FEEDBACK TO THIS TIP

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.

If you just need generic validation, such as the field contains text or a number, write a bit of JavaScript or LotusScript that accepts and array of field names and type and can do the generic validation for you.

—Brent H.

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.

Dig Deeper on Lotus Notes Domino Formula Language

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close