Using Dreamweaver Spry validation with jQuery ajax form plugin

Writing form validation code manually is a boring task. Not only that, editing or adding new fields each time and modifying the validation code accordingly is such a pain. When Dreamweaver added the Spry form validation with CS3 the nightmare is over. The greatest feature of using it is you can do the form validation work automatically with a couple of mouse clicks and no hand written code! And you can easily change/edit or add/remove the fields.

I know jQuery has simple validation plugin but you have to write the codes for it, which is time consuming. I always use the spry validation of dreamweaver as I learned using it for it’s simplicity. When I tried to use it with the jQuery ajax form submit plugin I got disappointed. It didn’t work! I didn’t stop trying. And finally I found the way which I’m gonna share with you :)

Here is the simple code that you need in the “beforeSubmit” parameter of $.ajaxForm

$("#formID").ajaxForm({
    url: "submit.php",
    beforeSubmit: function(formData, jqForm, options){
        if (Spry) { // checks if Spry is used in your page
            var r = Spry.Widget.Form.validate(jqForm[0]); // validates the form
            if (!r)
                return r;
        }
    },
    success: successFunction,
    complete: completeFunction
});

Hope that’ll help a lot boosting your web development.

Related posts:

  1. jQuery cycle plugin as carousel
  2. IE6 png alpha transparency fix for dynamically loaded images via ajax
  3. Gmail uploader clone with drag drop feature : Free Download with source code
  4. AJAX and SEO – Is it possible to get them together?
  5. Advanced cycle plugin integration

6 Comments to “Using Dreamweaver Spry validation with jQuery ajax form plugin”

  1. Hey, nice post, really well written. You should post more about this.

  2. Manu Vs 13 July 2009 at 12:41 pm #

    How did U applay this on your page ….
    Any examples….
    Me also facing the same problem

  3. Rudy 9 November 2009 at 11:53 pm #

    Hello,

    My name is Rudy and after examining your website, I believe I can help you improve your Search Engine Rankings.

    Do you wish you could increase your online leads? Getting much more traffic from search engines?
    It is much easier and more cost-effective than you might think. We have helped a lot of businesses thrive in this market and we can help you!
    Contact me at seo.rudy@gmail.com and I’ll share with you the cost and the benefits. See you at the top!

  4. Ben 18 May 2010 at 12:01 am #

    This was a lifesaver. Thank you very much!

  5. ABM Adnan 18 May 2010 at 1:39 am #

    you are most welcome @Ben

  6. Drew 15 July 2010 at 1:10 am #

    Thanks a lot! it worked like magic…


Leave a Reply