If you're like me and not really a domino developer, but a bit of everything, then you probably don't have a lot of time to spend on learning all the tips and tricks of domino. Often, creating a database is simply a matter of "knocking together" forms and views that will do the job and putting only minimal validation in place.
The problem is that normal built-in notes validation is awful on the web. You need to submit a form and get a validation "knockback" then click the back button in your browser and re-fill in the form. (Unless you have a modern version of firefox which seems to remember form data prior to submission).
About our Example Form
In order to explain this example, we need to have a form that we can display on the web. For the purpose of display, I'm going to assume that we have this simple form.
It has three fields on it.
It also has one button.
The validation rule that we're going to apply is simply that no field can be blank. Both fields are to be mandatory.
oh, and the Designer client I'm using is 7.0.2
So, here goes...
The JS Header
Open your form in Designer and look for the JS Header part of the form (on the Objects Tab).
The code is as follows;
(my apologies for using images - I was just worried about it being interpreted by blogger).
You should notice that each field has three bits that should be modified;
- The alert message telling you what is wrong
- The if (f.FirstName.value=="") bit which specifies the field to be checked
- f.FirstName.focus(); bit which refocuses the cursor on the offending field.
The OnClick Event
Apparently, and I don't know the reasons for this, you also have to have the following on the same button under Client and Formula
The $$Return Field
These changes should be enough to get your form working but I've discovered that a lot of people don't know about the $$Return field, so it's probably worth mentioning it too.
The $$Return Field should be a hidden (from Notes and Web) computed field
The formula for this field should be something like the following - though you'd probably replace the google.com reference with the address of a "thank you for submitting" page in your database.
So now, you should have a form you can use.
If your database is called mydatabase.nsf and if it's in the \test folder of your server and if your form is called myform, then you should be able to get to the database by doing the following;
Depending on security, you might not need &Login
also; if you don't have a domain (for the mydomain.com bit), you could simply use the IP Address of your server if you're inside the firewall.
Right, so now that you can test for blanks, you can start modifying the code to test for more exciting things.