Tutorijali.Net forum

Full Version: Kako napraviti za <textarea> limit?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pozdrav.

Dali neko zna kako da napravim ili gdje ima da se skine free skripta za textarea limit

ja sam našo na netu ovu skriptu
Code:
<html>
<header>

<script src="jquery.js" type="text/javascript"></script>


</header>

<body>



<textarea class="word_count" rows="5" cols="40">poipiopipi</textarea>
<br/>
<span class="counter"></span><br />

<script type="text/javascript">
$(document).ready(function(){
    /**
     * Character Counter for inputs and text areas showing characters left.
     */
    $('.word_count').each(function(){
        //maximum limit of characters allowed.
        var maxlimit = 240;
        // get current number of characters
        var length = $(this).val().length;
        if(length >= maxlimit) {
            $(this).val($(this).val().substring(0, maxlimit));
            length = maxlimit;
        }
        // update count on page load
        $(this).parent().find('.counter').html( (maxlimit - length) + ' characters left');
        // bind on key up event
        $(this).keyup(function(){
        // get new length of characters
        var new_length = $(this).val().length;
        if(new_length >= maxlimit) {
                $(this).val($(this).val().substring(0, maxlimit));
                //update the new length
                new_length = maxlimit;
            }
        // update count
        $(this).parent().find('.counter').html( (maxlimit - new_length) + ' characters left');
        });
    });

});
</script>

</body>
</html>

al mi se ne svidja pošto imam više textarea polja na stranici.

Znali neko kakvu jednostavniju skriptu?

Hvala!
Code:
<textarea id="area1"></textarea>
<p id="counter_area1"></p>

<textarea id="area2"></textarea>
<p id="counter_area2"></p>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" />
    var display = new Object();
    
    function forceLimit(elName, limit) {
        display[elName] = $("#counter_" + elName);
        
        $("#" + elName).keyup(function() {
            if (this.value.length > limit) {
                this.value = this.value.substr(0, limit);
            }
        
            display[elName].html(this.value.length + " of " + limit);
        });
    }
    
    forceLimit("area1", 10);
    forceLimit("area2", 20);
</script>

Možda bi bilo praktično da odvojiš ovo u poseban js fajl, pa da ti bude ovako:

Code:
<textarea id="area1"></textarea>
<p id="counter_area1"></p>

<textarea id="area2""></textarea>
<p id="counter_area2"></p>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="textarea.limit.js"></script>
<script type="text/javascript" />
    forceLimit("area1", 10);
    forceLimit("area2", 20);
</script>
a dali neko zna gdje mogu skinuti jquery skriptu WYSIWYG Editor
koji ima image menager?

Hvala!
Imaš brdo tih WYSIWYG editora, tinyMCE je jedan od njih, samo malo progooglaj.
(04-06-2011 04:15 PM)schmrz Wrote: [ -> ]Imaš brdo tih WYSIWYG editora, tinyMCE je jedan od njih, samo malo progooglaj.

ja al nema ni jedan image menager nako nešto kao wordpress.

Dali mi možeš reći kako da napravim image menager za tinymce?
Reference URL's