0

我目前有一个表单可以禁用基于两个文本字段的发送按钮。一个字段是一个消息框。我想拥有它,这样一个人就不能只放一堆入口和空间。我目前检查空格,但 charAt 只返回一个空格:/ 这是我希望它的样子:

        _sendComposeBtn.visible = true;

              // if the length of the message is zero, don't let people send it
        if (_messageLength == 0)
        {
            trace("hiding");
            _sendComposeBtn.visible = false;
            _realMessage = false;
        }


        _allSpaces = true;
              // start with allSpaces true. If there is a nonspace (or non-enter character then hide send button                
        for (i = 0; i < _bigMessageTextField.length; i++)
        {
            if (_bigMessageTextField.text.charAt(i) != " " && _bigMessageTextField.text.charAt(i) != (ENTER_CHARACTER))
            {
                trace("not a space");
                _allSpaces = false;
            }
        }

        if (_allSpaces == true)
        {
            _sendComposeBtn.visible = false;
        }
4

1 回答 1

0

你可以说:

_bigMessageTextField.text.charAt(i) != String.fromCharCode(13)
于 2013-06-28T14:41:39.410 回答