Using an Email Validation Widget
Bookmark :
Best practices for writing Domino apps has you put a server-side validation on data input as well as client-side validation. Why both? Because there's nothing to keep the internet user from spoofing your form and submitting malicious data directly to your back-end, so you need server-side validation. Why client-side? For useability, it stinks to go through an entire form, submit it, and then get a bunch of errors that need to be fixed. It's nice to have immediate feedback.
Ok, so you've been doing Notes forever and you have a good @formula for your server-side email field. Now you're thinking, crud, I've got to take this thing and write it in javascript and then figure out how I want to display an error to the user...do I put it next to the field, do I pop up an alert box. Dang it...why do I have to go to all this extra work !!!
If you're using Dojo, you can make this part of your life simpler. More...
- Create a shared $$HTMLHead field and drop it in your form(s) where you're doing dojo. The field contains this:
"<script type=\"text/javascript\" src=\"dojo.js\"></script>"
- In the JSHeader for the form, add this line:
dojo.require('dojo.widget.Textbox');
- In the properties box for your email field, go to the HTML tab, fillin the "ID" field and the "Other" field. The "Other" field should have something like this:
dojoType="EmailTextBox" widgetId="EmailAddress"

And guess what, the validation is probably better than what you would provide yourself. For example, it knows that .xyz is not a valid domain, and it also knows that both .au .co and .com ARE valid. I know my validations weren't that sophisticated.
Want to see it in action? Try it Email Widget Demo.
Download the zipped db here. Enjoy!

