Not signed in (Sign In)

Vanilla 1.1.5a is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthordbuschho
    • CommentTimeFeb 23rd 2009
     
    This was requested a while back, but there has been some interest in it:

    <script type="text/javascript">
    wFORMS.behaviors.validation.rules.isUnderLimit = { selector: ".validate-length", check: 'isUnderLimit' }
    wFORMS.behaviors.validation.messages.isUnderLimit = "This text is too long.";

    wFORMS.behaviors.validation.instance.prototype.isUnderLimit = function(element, value) {

    var pattern = new RegExp(/validate-length (\d*)/i);
    var matches = element.className.match(pattern);

    if(matches && matches[1]) {
    return (value.length <= matches[1]);
    }
    return true;
    }


    base2.DOM.Element.addEventListener(document,'DOMContentLoaded',function(){
    document.getElementById("tfa_Description").className = "required validate-length 256";
    },false);
    </script>

    This will limit the text field 'tfa_Description' to a length of 256 characters. By changing the value of the integer constant you can of course change that limit.