The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
5 posters

    Words problem in Javascript

    Winging
    Winging
    Forumember


    Female Posts : 149
    Reputation : 4
    Language : traditional chinese

    Solved Words problem in Javascript

    Post by Winging November 21st 2020, 9:26 am

    Forum version : #phpBB2
    Position : Founder
    Concerned browser(s) : Google Chrome
    Who the problem concerns : Yourself
    Forum link : https://ekin-ek.666forum.com/

    - - - - - - - - -

    If I use this code,the navigation bar will disappear.(And,close code,it will recover.)

    →In the topics:Limiting the number of words has no effect.
    →In all the pages:Can limit the number of words, but the mobile navigation bar will disappear.


    I don't know why. Neutral

    【From https://help.forumotion.com/t121475-minimum-character-post?highlight=minimum+characters

    Code:
    $(function() {
    var x=document.forms['post'];
    $(x.post).click(function(e) {
     if (x.message.value.length < 10) {
      e.preventDefault();
      alert('Your post must contain at least 10 character');
     }
    });
    });

    Words problem in Javascript A13


    Last edited by Winging on November 23rd 2020, 2:00 pm; edited 2 times in total
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Solved Re: Words problem in Javascript

    Post by skouliki November 21st 2020, 9:48 am


    Winging
    Winging
    Forumember


    Female Posts : 149
    Reputation : 4
    Language : traditional chinese

    Solved Re: Words problem in Javascript

    Post by Winging November 21st 2020, 11:03 am

    skouliki wrote:hello

    the code is old maybe you want to try this one https://help.forumotion.com/t131191-add-a-word-counter-to-the-editor?highlight=editor+limit

    thank you for your reply @skouliki

    I try,and I find it can't count words in chinese.

    Is it because Chinese belongs to Pinyin?

    Even if my word count reaches the limit target (at least 5 words),【green】
    Still did not count any 1 word.【red】

    Words problem in Javascript Yz11
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Solved Re: Words problem in Javascript

    Post by skouliki November 21st 2020, 5:09 pm

    may i ask...is your forum language set in Chinese as well ? from the admin panel

    TonnyKamper likes this post

    Winging
    Winging
    Forumember


    Female Posts : 149
    Reputation : 4
    Language : traditional chinese

    Solved Re: Words problem in Javascript

    Post by Winging November 23rd 2020, 8:34 am

    skouliki wrote:may i ask...is your forum language set in Chinese as well ? from the admin panel
    Yes,it is in chinese set.
    And,I just found out recently.
    I have to switch editing mode(in Code mode),it can calculate.(Some times)
    Is this normal?

    Thank your reply @skouliki
    SarkZKalie
    SarkZKalie
    Support Moderator
    Support Moderator


    Male Posts : 1442
    Reputation : 220
    Language : English

    Solved Re: Words problem in Javascript

    Post by SarkZKalie November 23rd 2020, 9:11 am

    A word should be more than 3 characters, i.e Hello



    Words problem in Javascript Sarkzk10
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Solved Re: Words problem in Javascript

    Post by skouliki November 23rd 2020, 9:24 am

    i really dont know why the code is not working properly with Chinese but i will tag my friend @pedxz he is a good coder and he might help you with this

    tikky likes this post

    tikky
    tikky
    Forumember


    Posts : 922
    Reputation : 159
    Language : 🇵🇹

    Solved Re: Words problem in Javascript

    Post by tikky November 23rd 2020, 1:35 pm

    Hello @Winging!

    In the code find:
    Code:
    var regex = new RegExp('\\w{' + LetterCountPerWord + ',}\\b', 'g');
    replace to:
    Code:
    var regex = /[^\x00-\xff]/g;

    TonnyKamper likes this post

    Winging
    Winging
    Forumember


    Female Posts : 149
    Reputation : 4
    Language : traditional chinese

    Solved Re: Words problem in Javascript

    Post by Winging November 23rd 2020, 1:57 pm

    pedxz wrote:Hello @Winging!

    In the code find:
    Code:
    var regex = new RegExp('\\w{' + LetterCountPerWord + ',}\\b', 'g');
    replace to:
    Code:
    var regex = /[^\x00-\xff]/g;
    wow! Thank @pedxz

    This can work,and solved my problem.

    You are very smart!!!

    Thank you very much.

    And I am also grateful @skouliki @SarkZKalie very much.

    You are very friendly. Very Happy

    (And I will mark solved Smile )

    SarkZKalie and tikky like this post

    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Words problem in Javascript

    Post by TheCrow November 23rd 2020, 2:11 pm

    Thank you @pedxz,

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules



    Words problem in Javascript Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!

    tikky likes this post


      Current date/time is September 22nd 2024, 7:36 pm