Count characters/sms using jQuery

后端 未结 11 1664
醉酒成梦
醉酒成梦 2020-12-08 17:23

I count characters using NobleCount and the following code:

$(\'#message\').NobleCount(\'#messageInfo\',{
            max_chars: getMaxChars(),
            o         


        
11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 17:36

    Once the message has been decoded as Craig McQueen stated in a this thread post and you have your actual character count, to count the needed SMS amount the following is enough:

    function cntsms(len){ return len<=0? 0: (len>160? Math.ceil(len/153): 1); }
    

    ...I like one-row solutions so much.

提交回复
热议问题