Good art is a taste, good design is an opinion.


Come as guest, stay as family.
Board Index

Come as guest, stay as family.


You are not connected. Please login or register

Foto

[Solved] Word count before user is able to post



View previous topic View next topic Go down Message [Page 1 of 1]

1
Offline

  Guest

Anonymous
Guest
Details:
Pubb-Design,

Hello I'm taking the time to post this I was wondering how I add the below in the image.

[Solved] Word count before user is able to post Screen10

Your Forum Address:
www.google.com

Forum Version:
PunBB

Powered by PunBB
Currently 0 users have thanked Guest for this post:

2
Offline

  Shadow

Shadow
Administrator
Administrator
Put this in your Javascript.
Code:
[panda=js]$(function(){$(function(){

      var numeroMinimoPalabras = 4;
      var longitudMinimaPalabra = 2;
      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'>Words minimum to send a message: " + numeroMinimoPalabras + " (at least " + longitudMinimaPalabra + " letters)</div><div id='div_minchars_info'></div></div>");
         
          var sceditor = $("#text_editor_textarea").sceditor("instance");                 
          var str = sceditor.val();
          var regex = new RegExp('\\w{' + longitudMinimaPalabra + ',}\\b', 'g');
          var str_arr = str.match(regex);
          var str_len = str_arr == null ? 0 : str_arr.length;
         
          if(str_len >= numeroMinimoPalabras) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
         
          sceditor.keyUp(function(e) {
            str = sceditor.val();
            str_arr = str.match(regex);
            str_len = str_arr == null ? 0 : str_arr.length;
            if(str_len >= numeroMinimoPalabras) {
                $("#div_minchars_info").html("You wrote <span style='color:green'>" + str_len + "</span> word(s). You can send the message <img src='" + ico_compl  + "' />"); 
                $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
            }else{
                $("#div_minchars_info").html("You wrote <span style='color:red'>" + str_len + "</span> word(s). You need " + (numeroMinimoPalabras - str_len) + " more word (s) to write this message <img src='" + ico_incompl  + "' />");
                $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
            }
          });
      }
    })});

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

3
Offline

  nanako

nanako
Punbb Guru
Punbb Guru
Next time, post your real forum address or else your thread will not be answered.

Powered by PunBB
Currently 0 users have thanked nanako for this post:

4
Offline

  Guest

Anonymous
Guest
code you provided doesn't work.

Powered by PunBB
Currently 0 users have thanked Guest for this post:

5
Offline

  Shadow

Shadow
Administrator
Administrator
The code itself works perfectly, just tested on demo boards and everything is fine.

The problem may be you use too much javascripts, heavily edited template or DOM errors with another javascript.

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

6
Offline

  Guest

Anonymous
Guest
I apologize shadow I removed all codes and scripts I had and its working fine thanks for providing the code and I apologize for not providing my forum URL the reason being I didn't want it released till my forum was complete.

Please mark this thread solved thanks

Powered by PunBB
Currently 0 users have thanked Guest for this post:

7
Offline

  nanako

nanako
Punbb Guru
Punbb Guru
Solved and Locked.

Powered by PunBB
Currently 0 users have thanked nanako for this post:

8
Offline

  Sponsored content



Powered by PunBB
Currently 0 users have thanked Sponsored content for this post:

View previous topic View next topic Back to top Message [Page 1 of 1]


Topic URL's

URL
BBcode
HTML

Permissions in this forum:
You cannot reply to topics in this forum