Hoy en AyudaWordPress.com | ![]() |
Limitador de caracteres en comentarios Posted: 10 Dec 2011 07:12 AM PST En estos tiempos en que nos están acostumbrando a limitar lo que escribimos en la red, en concreto en Twitter, igual no se le hace tan raro a nuestros visitantes un contador de caracteres en los comentarios ¿no crees?. Si eres de los que reciben auténticas parrafadas infumables en los comentarios de tu sitio igual este código
jQuery(function($) { // Configuración. Pon en comment_limit_chars el número de caracteres máximo var comment_input = $( '#commentform textarea' ); var submit_button = $( '#commentform .form-submit' ); var comment_limit_chars = 140; // deja de hacer modificaciones aquí // display how many characters are left $( '<div class="comment_limit_info"><span>' + comment_limit_chars + '</span> characters left</div>' ).insertAfter( comment_input ); comment_input.bind( 'keyup', function() { // calculamos cuantos caracteres quedan var comment_length = $(this).val().length; var chars_left = comment_limit_chars - comment_length; // mostramos los caracteres que quedan $( '.comment_limit_info span' ).html( chars_left ); // oculta el botón de envier si se ha sobrepasado el límite de caracteres if (submit_button) ( chars_left < 0 ) ? submit_button.hide() : submit_button.show(); }); }); El código inserta automáticamente una tag Código ofrecido por Eric Teubert de www.satoripress.com a WP Engineer. |
You are subscribed to email updates from Ayuda WordPress To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No hay comentarios:
Publicar un comentario