Loading ...
Sorry, an error occurred while loading the content.

Form Validation with YUI

Expand Messages
  • juliusdietz
    Hi, does it make sense and is there a module in the YUI to do client side form validation with YUI? Thanks
    Message 1 of 4 , Aug 25, 2006
    • 0 Attachment
      Hi,

      does it make sense and is there a module in the YUI to do client side
      form validation with YUI?

      Thanks
    • Eric Miraglia
      Julius, There is no module in YUI specific to form-field validation. However, the YUI toolkit provides a lot of functionality you can use in such an exercise
      Message 2 of 4 , Aug 28, 2006
      • 0 Attachment
        Julius,

        There is no module in YUI specific to form-field validation.  However, the YUI toolkit provides a lot of functionality you can use in such an exercise — Event Utility for listening for blur/change events, Connection Manager for doing server-side validation where desired, etc. 

        Regards,
        Eric

        ______________________________________________
        Eric Miraglia
        Yahoo! Presentation Platform Engineering


        On Aug 25, 2006, at 8:23 AM, juliusdietz wrote:

        Hi,

        does it make sense and is there a module in the YUI to do client side
        form validation with YUI?

        Thanks


      • Francisco
        Julius, I have plugged the YUI into my XForms implementation so that YUI widgets becomes XForms controls. For persons unaware of of XForms, it is the latest
        Message 3 of 4 , Aug 29, 2006
        • 0 Attachment
           
          Julius,
           
          I have plugged the YUI into my XForms implementation so that YUI widgets becomes XForms controls. For persons unaware of of XForms, it is the latest W3C specification which replaces HTML 4 forms plus more. XForms allows fields to be validated according to W3C schema rules or allows nodes to declaratively as binds. For more on XForms pls see www.w3c.org
           
          Kind Regards
          Francisco

          From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Eric Miraglia
          Sent: 29 August 2006 05:31
          To: ydn-javascript@yahoogroups.com
          Subject: Re: [ydn-javascript] Form Validation with YUI

          Julius,


          There is no module in YUI specific to form-field validation.  However, the YUI toolkit provides a lot of functionality you can use in such an exercise — Event Utility for listening for blur/change events, Connection Manager for doing server-side validation where desired, etc. 

          Regards,
          Eric

          ____________ _________ _________ _________ _______
          Eric Miraglia
          Yahoo! Presentation Platform Engineering


          On Aug 25, 2006, at 8:23 AM, juliusdietz wrote:

          Hi,

          does it make sense and is there a module in the YUI to do client side
          form validation with YUI?

          Thanks


        • oct3six
          I started using CSS classes to validate input fields on the client a long time ago, but the YUI Dom.hasClass and Dom.replaceClass functions make the technique
          Message 4 of 4 , Aug 29, 2006
          • 0 Attachment
            I started using CSS classes to validate input fields on the client a
            long time ago, but the YUI Dom.hasClass and Dom.replaceClass
            functions make the technique much more elegant. Two greatest
            functions evar. (addListener is a close third)

            Here is a link to a live demo, but i've included the js snippet
            below for reference. It really only works for text boxes and text
            areas. Just set the class="required" for all the required fields.
            Add some css styles for a little flair.

            http://www.demoniusrex.com/CSSFormValidator/

            /**********************
            * cssFormValidator *
            * David Morrison *
            * 8/29/06 *
            **********************/

            // http://www.demoniusrex.com/cssformvalidator

            // requires yahoo.js and dom.js from the YUI library
            // http://developer.yahoo.com/yui/

            var CSSFormValidator = function(formName) {
            var f = document.getElementById(formName);
            if (f) {
            var i = f.getElementsByTagName("input");
            for(var q=0; q<i.length; q++) {
            if(checkInput(i[q])) {
            // field ok
            } else {
            return false;
            }
            }
            return true;
            } else {
            return false;
            }
            };

            var checkInput = function (i) {
            if (YAHOO.util.Dom.hasClass(i,"required")) {
            if(i.value == "") {
            YAHOO.util.Dom.replaceClass(i,"complete","incomplete");
            return false;
            } else {
            YAHOO.util.Dom.replaceClass(i,"incomplete","complete");
            }
            }
            return true;
            };


            --- In ydn-javascript@yahoogroups.com, "juliusdietz"
            <juliusdietz@...>
            wrote:
            >
            > Hi,
            >
            > does it make sense and is there a module in the YUI to do client
            side
            > form validation with YUI?
            >
            > Thanks
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.