下面是我已經寫和它的正常工作:字符類型檢測
var $remaining = $('#remaining'),
$messages = $remaining.next();
$('#message').keyup(function(){
var chars = this.value.length,
messages = Math.ceil(chars/160),
remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
$remaining.text(remaining + ' characters remaining');
$messages.text(messages + ' message(s)');
}); This is the above code in action
現在我想要做的是:
var text_max_En = 100;
var text_max_utf8 = 200;
if /* what user has typed is English */
{
Do this
}
else if /* what user has typed is in utf8 type*/
{
Do that
}
簡而言之:
**If**
用戶在輸入英文有那麼它應該數到每個消息
AND **if**
這是在urf8類型,那麼就應該數到200人。
任何解決方案?
嘗試編寫幹,使您的問題更加明顯。 – Andries 2013-04-10 16:52:40
不好意思,幹嗎? – John 2013-04-10 16:57:49
'utf8 type'是什麼?你能給個例子嗎? – 2013-04-10 17:02:29