How to use a javascript library

I am fairly new at Notes/Domino development and I hava a question about how to utilize a javascript library. I am designing a Domino web database that contains three forms and I want to use a javascript library to do field validation on a number of shared fields. I have created the javascript library through Designer, added it as a resource to the “JS Header” on my forms, and am now wondering how to trigger the script. I have tried calling the validate function from the “onSubmit” event on the forms, but that did not seem to do it. I have been searching through the posts on this forum, but most of the posts on this subject seem to deal with LotusScript libraries in a Notes environment, rather than Javascript libraries in a Domino/Web development environment.

Any help is greatly appreciated.

Subject: How to use a javascript library

It depends on how you are saving the document as the onsubmit event is only triggered by @command([filesave]).

Using document.forms[0].submit() will not trigger the onsubmit event.

If you are using an action button call the function validate() and in the last line of the function add document.forms[0].submit();

Subject: How to use a javascript library

view the source of the html document that is generated and ensure that both your library and the onSubmit code is there.The library should be listed in the header and onSubmit in the form tag.

If the onSubmit is not there, go back to the design of you form, click on the onsubmit event, and ensure in the code panel next to “Run” it says Web and not Client"

If everything is there as it should be in the webpage, get firefox and run the page. After you run it under tools-javascript console see if there are any errors.

Subject: RE: How to use a javascript library

Never mind ‘if everything is there as it should be’ - get firefox regardless!! That console will save you hours of aggrevation.

Shawn

Subject: RE: How to use a javascript library

good point, get the firebug add-on while you are there also

Subject: Understand your environment

I am fairly new at Notes/Domino development and I hava a question about how to utilize a javascript library.

The answer to your question would be the same in any ‘web development’ environment. The only thing different in Domino is the Designer UI.

If you don’t know HTML, CSS and Javascript learn it outside of Domino - the Designer support for CSS and Javascript are not the best in the world.

The Eclipse IDE is probably a good choice being as how Designer R8 will be an Eclipse application but may be intimidating. Notepad ++ does a fine job which is why I store Javascript as file resources rather than ‘script libraries’.

Get the Oreilly books - there is a DHTML one that covers all three but I’d go for the latest version of the Javascript and CSS books and a second-hand HTML 4.01 tome.

Use Firefox with Firebug to debug. Check out the Selenium (web app test framework) plugin.

I want to use a javascript library to do field validation

Search www.codestore.net for validation. Download Jake’s sample and look at it. He uses ye olde $$HTMLHead field to pull JS and CSS files into the forms which has some advantages. Don’t try to understand ‘prototype.js’ or ‘effects.js’ for now.

on a number of shared fields.

Shared fields suck. Create a subform with the common fields on.

HTH