JS for minimum number of characters in yield

    <script language="JavaScript">

<!-- Begin
    maxLen = 315; // max number of characters allowed

    function checkMaxInput(form) {
        if (form.comments.value.length > maxLen) // if too long.... trim it!
            form.comments.value = form.comments.value.substring(0, maxLen);
            // otherwise, update 'characters left' counter
        else form.remLen.value = maxLen - form.comments.value.length;
    }
    //  End -->
    </script>
var comments = document.getElementById("comments").value

        if (comments.length > 315) {
            alert('The comment field can only hold 315 characters')
            return false;
        }

then…

  <textarea name=comments id="comments" wrap=physical cols=35 rows=5 onKeyDown="checkMaxInput(this.form)" onKeyUp="checkMaxInput(this.form)"></textarea>
<input readonly type=text name=remLen size=3 maxlength=3 value="315"> characters left

I am using the above code for max. characters. Not sure how to alter, if possible, for also at least requiring a MINIMUM of “x” characters.

Any help would be appreciated.

Thanks

Actually, I don’t need this after all. I found a way of doing this with a placeholder message in the field and then I used an asp len function to response.write and response.end the message if less than x characters. Thank you.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.