javascript ValidationDecorator

//Dependency on the following /* function.js jQuery ver 1.5.1 jquery.validationEngine.js jquery.validationEngine-en.js */

by Terrance Smith

JavaScript

//Dependency on the following
/*
    function.js
    jQuery ver 1.5.1
    jquery.validationEngine.js
    jquery.validationEngine-en.js

*/

//Singleton
ValidationDecorator = function() {

    //Private
    //commonly used custom validation enum of decorators for elements 
    var CUSTOM_VALIDATION_CLASS_ATTRIBS = {

        //D - Date
        //DT - DateTime
        //RQ - Required Field
        //RNG - Range - checks against a range
        D: "validate[custom[dateFormat]",
        //field must have correct date format
        D_RQ: "validate[required,custom[dateFormat]",
        //field must have correct date format and is *required*
        D_RNG: "validate[dateRange[{0}],custom[dateFormat]]",
        //field must have correct date format and date range
        D_RQ_RNG: "validate[required,dateRange[{0}],custom[dateFormat]]",
        //field must have correct date time format and date range and is *required*
        DT: "validate[custom[dateTimeFormat]]",
        //field must have correct date time format
        DT_RQ: "validate[required,custom[dateTimeFormat]]",
        //field must have correct date time format and is *required*
        DT_RNG: "validate[dateTimeRange[{0}],custom[dateTimeFormat]]",
        //field must have correct date time format and date range
        DT_RQ_RNG: "validate[required,dateTimeRange[{0}],custom[dateTimeFormat]]" //field must have correct date time format and date range and is *required*
    };

    //_appendClassbindings  - Used for late binding of validation decoration to element classes
    //elementId- the element to bind
    //the attributes to bind (see CUSTOM_VALIDATION_CLASS_ATTRIBS)
    var _appendClassbindings = function(elementId, classAttribs) {
        document.getElementById(elementId).className += classAttribs;
    };
    var _appendToValidationGroup = function(elementId, groupName, attrib) {
        var attrib = CUSTOM_VALIDATION_CLASS_ATTRIBS.D_RNG.replace("{0}", groupName);
       ...