Rich Waters

Ext, Javascript, Notes/Domino, Ext.nd, Ruby on Rails

Show 'n Tell Thursday
For anyone who read my past article on the extensible javascript validation class(es) that I wrote, the true intention was for easy use on a domino form. So lets take a look at how to add it in.

  1. First off it is based on the great Prototype Library, pick it up if you haven’t already.
  2. grab my validation class, create 2 new javascript libraries and copy the code into them.
  3. Open up the form you wish to add validation to and go to the ‘JS Header’ section.
  4. Create>Resource>Insert Resource – select prototype.js
  5. Repeat for validate.js
  6. Go to the ‘onLoad’ event for the form and create a validation object, as long as you dont have any pass through form tags on the field you can reference the form via ‘0′ or ‘_formname’ using the name of your form (Example: new Validation(“_contact”); )
  7. Ok now pick which fields you want to validate, select the field and open the field properties
  8. on the HTML tab (last one) you can set the class values that will pass through to the html tag, all fields you want to validate must include the ‘validate’ class.
  9. Also add a class based off which type of validation you want, built in choices are: numeric, date, email, phone, zip, password, name, required.

An example class for email validation would be ‘validate email’
Save the form and you’re done. I posted a bit more previously on how it handles validation and plan to write some information on how to customize it to your needs and add additional validator objects to it.
Technorati:

Share and Enjoy:
  • Digg
  • Facebook
  • Google Bookmarks
  • Posterous
  • RSS
  • Twitter
U Comment, I Follow - Heavily moderated, SPAM will be dealt with.

10 Responses to “SnTT 1: Easy JS Validation on a Form”

  1. [...] If your doing Domino web work take a look at “SnTT 1: Easy JS Validation on a Form, although (evil thought) I wonder if something like this could work in the notes client javascript support? You still need back end validate though. (which leads to another evil thought – 2 in one morning? !!) about using RSJ templates to generante the javascript for validatation based on the RubyOnRails meta data … hmm) [...]

    False Positives » Blog Archive » SnTT : LotusScript Required Field Validation without pain

  2. good

    revathi

  3. Very neat.
    i question – if a field needs two validations – say required and email, is that possible? i tried ‘validate required email’ but didnt work.

    vinay

  4. ‘validate required email’ is one I’ve used and had working, was anything else changed? do they work separately? I’ll try my best to help figure out whats not working.

    Rich Waters

  5. [...] I then went through a couple of other basic examples using Prototype / Scriptaculous, including a quick ajax autocompletion and a demo of my prototype based javascript validation. [...]

    Rich Waters » Blog Archive » Condug Presentation

  6. Hej, can you send / post a working example? I have implemented your code but there is no validation running when I submit my form…

    Thanks in advance

    Patrick Kwinten

  7. Patrick,
    did you make sure to change the bottom section to correspond to your form name?
    Event.observe(window,”load”,function() {
    var val = new Validation(“_contact”);
    });

    Rich Waters

  8. Patrick,
    this may be a slightly older version, but it shows the validation working on a form:
    http://www.rich-waters.com/blog/code/demo.html

    Rich Waters

  9. Hello. And Bye.

    XRumerTest

  10. http://www.tootobuy.com gsm phone wholesale phones slider phone china cellphone

    vincent

Leave a Reply