about word counter
+2
Ange Tuteur
Ahmed.K
6 posters
Page 1 of 2
Page 1 of 2 • 1, 2
about word counter
About this code:
https://help.forumotion.com/t131882-just-one-last-change-at-the-word-counter#885030
the code works fine. but ...
It doesn't work when i copy/paste any text (of course more than 50 characters) without pressing any key on the keyboard.
After searching in Google, I tested this ...
sceditor.on('keyup change', function(e){
instead of
sceditor.keyUp(function(e) {
But it doesn't work too. Any ideas?
https://help.forumotion.com/t131882-just-one-last-change-at-the-word-counter#885030
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
sceditor.keyUp(function(e) {
str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
});
}
})});
the code works fine. but ...
It doesn't work when i copy/paste any text (of course more than 50 characters) without pressing any key on the keyboard.
After searching in Google, I tested this ...
sceditor.on('keyup change', function(e){
instead of
sceditor.keyUp(function(e) {
But it doesn't work too. Any ideas?
Last edited by Ahmed.K on Thu 27 Nov - 19:50; edited 1 time in total
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
Hello Ahmed,
Try replacing your script with this :
Try replacing your script with this :
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
It works now!
But can we count only the letters (english letters) and numbers? Not #, $ , . *,....
But can we count only the letters (english letters) and numbers? Not #, $ , . *,....
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
Try now :
I added some characters to the filter.
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:|[!@#$%\^&\*\(\)\[\]`~;:'"<,>\.\?\/_-=+]+/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
I added some characters to the filter.
Re: about word counter
Oops, I made a mistake, try now :
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:|[!@#$%\^&\*\(\)\[\]`~;:'"<,>\.\?\/\_\-\=\+]+/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
It works well, but what about the english letters?
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
Yes, i mean only the english letters should be counted, not any language else.
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
Try this then :
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/\W/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
Please change the title of your topic to something that is related to your question/issue, so that other users will be able to find their question/issue using the search engine.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: about word counter
This one works perfect, Ange.
But can you disable counting the emoticon?
Emoticon like this: :sm015: :sm01: :sm019: :sm09: :sm04: :sm05: :sm06:
But can you disable counting the emoticon?
Emoticon like this: :sm015: :sm01: :sm019: :sm09: :sm04: :sm05: :sm06:
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/(:.*?:|\W)/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
This one is solved too.
Last thing Can you disable counting anything between this [quote ][/quote] too?
Last thing Can you disable counting anything between this [quote ][/quote] too?
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
this should work
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[quote\].*?\[\/quote\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/(:.*?:|\W)/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
Not sure, but try this :
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/(:.*?:|\[.*?\].*?\[\/.*?\]|\W)/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
@_Twisted_Mods_, no, doesn't work.
@Ange, yes, it works good in the quickreply mode, when i copy/paste any quote [quote ][/quote].
But when i click on the quote button on any post and i go to the advanced mode, i find the Send button is enable. and i can send without writing anything. but when i start to write anything less than 50, i find that the Send button is disabled.
And doesn't work at all if the quote like this: [quote="Admin"]test [b]test[ /b] test [ /quote].
@Ange, yes, it works good in the quickreply mode, when i copy/paste any quote [quote ][/quote].
But when i click on the quote button on any post and i go to the advanced mode, i find the Send button is enable. and i can send without writing anything. but when i start to write anything less than 50, i find that the Send button is disabled.
And doesn't work at all if the quote like this: [quote="Admin"]test [b]test[ /b] test [ /quote].
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
No solution to this problem?
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
Please do not reply unless you are offering a solution.ryanzkie wrote:
- what a good day:
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: about word counter
You can try this :
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/(:.*?:|\W)/gi,'').replace(/\[.*?\].*?\[\/.*?\]/,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
Still doesn't work. It is still counting everything between the quote.
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
Okay, give this a try :
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/\[.*?\].*?\[\/.*?\]/g,'').replace(/(:.*?:|\W)/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
No , still doesn't work if the quote like this: [quote="Admin"]test [b]test[ /b] test [ /quote].
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
Okay, see if this works for the quotes :
Also, your example has a space in the tag. If there's a space it wont format after posting or be replace by the regex.
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/(\[quote\]|\[quote=".*?"\]).*?\[\/quote\]/g,'').replace(/(:.*?:|\W)/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Also, your example has a space in the tag. If there's a space it wont format after posting or be replace by the regex.
Re: about word counter
Yes, i know.... I did that to show the example here.
The last code doesn't work with multiquote. like this:
The last code doesn't work with multiquote. like this:
- Code:
[quote="Admin"][quote="User"]text[/quote][/quote]
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
It seems to still work partially from what you've given.
I'm out of ideas for now, sorry.
I'm out of ideas for now, sorry.
Re: about word counter
I think i found an old solution by you, and it works fine with the multiquote mode.
https://help.forumotion.com/t134045-editor-word-counter#902533
I think we can use this part in our code to solve the multiquote problem:
But the only problem with this old solution, it counting the spaces in the quote.
https://help.forumotion.com/t134045-editor-word-counter#902533
I think we can use this part in our code to solve the multiquote problem:
- Code:
str = sceditor.val().replace(/\n/g,' ').replace(/\[quote=".*?"\].*?\[\/quote\]/gi,'').replace(/\[quote\].*?\[\/quote\]/gi,'').replace(/\[\/quote\]/gi,'').replace(/\[quote\]/gi,'').replace(/\[quote=".*?"\]/gi,'');
But the only problem with this old solution, it counting the spaces in the quote.
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Re: about word counter
Okay, give this a try :
- Code:
$(function(){$(function(){
var MinNumberOfChars = 50;
var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
if($("#text_editor_textarea").length != 0){
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
$(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
var sceditor = $("#text_editor_textarea").sceditor("instance");
var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
var str_len = str.length;
if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
$('.sceditor-container iframe').contents().on('input', function() { getLen() });
$('.sceditor-container textarea').on('input', function() { getLen() });
sceditor.keyUp(function() { getLen() });
}
function getLen() {
str = sceditor.val().replace(/\n/g,' ').replace(/\[quote=".*?"\].*?\[\/quote\]/gi,'').replace(/\[quote\].*?\[\/quote\]/gi,'').replace(/\[\/quote\]/gi,'').replace(/\[quote\]/gi,'').replace(/\[quote=".*?"\]/gi,'').replace(/(:.*?:|\W)/gi,'');
str_len = str.length;
if(str_len >= MinNumberOfChars) {
$("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl + "' />");
$("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
}else{
$("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl + "' />");
$("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
}
}
})});
Re: about word counter
Finally, Ange, the code now understand the multiquote system in the default mode (without any text) like this:
- Code:
[quote="Admin"][quote="User"][quote="User1"][/quote][/quote][/quote]
but still there one problem.
the code works well and doesn't count the text in the first quote, like this (text1):
- Code:
[quote="Admin"][quote="User"][quote="User1"] text1 [/quote][/quote][/quote]
but it count the text in the second and third quote, like this (text2 and text3):
- Code:
[quote="Admin"][quote="User"][quote="User1"] text1 [/quote] text2 [/quote] text3 [/quote]
Ahmed.K- Forumember
- Posts : 347
Reputation : 4
Language : English
Page 1 of 2 • 1, 2
Similar topics
» Word Counter Box
» Help with word counter?
» A word counter
» Add a word counter to the editor
» something not right i just noticed about word counter
» Help with word counter?
» A word counter
» Add a word counter to the editor
» something not right i just noticed about word counter
Page 1 of 2
Permissions in this forum:
You cannot reply to topics in this forum