Field validation for the Web

Field validation for the Web

This code allows a developer the easiest route to field validation. I have tried all the validation methods such as JavaScript, Validation fields etc.

I developed this after a many hours of trying to find the easiest, most portable way to validate fields. Nothing works as well as this one!

To use this formula, add a field to your form called FE. Make it "Computed for Display" with the value as FE. This will be a display field for your validation error message. Make it the color red, green, or something that stands out when the form returns validation errors.

Add the code into your submit button right before the code you use to process the form (save it, run agent or whatever).

I also have a JavaScript version of this code. Please email me if you like a copy at kamal@office.com.
Code: FIELD FE := FE;
F1 := FIELD1NAME;
F2 := FIELD2NAME;
F3 := FIELD3NAME;
F4 := FIELD4NAME;
F5 := FIELD5NAME;
ErrorMessage:= "There was an error in your form: ";

REM "ADD THIS CODE TO YOUR SUBMIT OR SAVE BUTTON RIGHT BEFORE THE REST OF YOUR CODE. ";
REM "IF YOU HAVE ANY FIELD DECLARATIONS IN YOUR CURRENT CODE, ADD THEM TO THEM UP AT TOP.";
REM "FIELD DECLARATIONS SHOULD ALWAYS BE AT THE TOP.";

REM " REFRESH FIELDS";
@Command([ViewRefreshFields]);

REM "THIS FORMULA VALIDATES FIELDS THEN PROCESSES FORM ONCE THE FIELDS ARE CORRECT.";
REM ;
REM "CHECK IF FIELD 1 IS VALID";

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.


a:=@If( F1="" ;@NewLine+ "Update Field One."; "" );

REM "CHECK IF FIELD 2 IS VALID";
b:=@If( F2="" ;@NewLine+ "Update Field Two."; "" );

REM "CHECK IF FIELD 3 IS VALID";
c:=@If( F3="" ;@NewLine+ "Update Field Three."; "" );

REM "CHECK IF FIELD 4 IS VALID";
d:=@If( F4="" ;@NewLine+ "Update Field Four."; "" );

REM "CHECK IF FIELD 5 IS VALID";
e:=@If( F5="" ;@NewLine+ "Update Field Five."; "" );

ems := @Trim(a+b+c+d+e);

@If( ems = "" ; @Success ; @Do(@SetField("FE";ErrorMessage+ems);
@Return("")));

REM "SAVE DOCUMENT OR RUN THE REST OF THE SUBMIT FORMULA HERE";
REM "ADD THE REST OF YOUR CODE HERE";
@PostedCommand([FileSave]);

REM "AFTER PROCESSING THE DOCUMENT SEND THEM TO A CONFIRMATION PAGE. ";
@PostedCommand([Compose];"ConfirmPage")

This was first published in April 2001

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.