下面是我已经写和它的正常工作:字符类型检测
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