0

Textbox 多行問題 急需

asked 2013-08-28 04:48:50 +0800

popo21423 gravatar image popo21423
0

updated 2013-08-28 04:49:24 +0800

請問我目前Textbox例如有設定rows="4" cols="35" 且css有設定英文自動斷行,但因為css的自動斷行並沒有補換行符號。 我的需求是他如果設定rows="4"就真的只能輸入4行。若超過就要拋警訊。 但若Css沒有補換行符號時,我有辦法抓到目前該Textbox內有幾Row的資料嗎?? 麻煩各位了...

delete flag offensive retag edit

2 Answers

Sort by » oldest newest most voted
0

answered 2013-08-30 20:11:42 +0800

roliroli gravatar image roliroli
164 4

據我所知 ZK 沒有這樣的功能。 我想其他 Framework 也沒這樣的功能,這應該是跟瀏覽器相關,HTML 規範相關的問題。 就算想要用 35 個字符去做一行也是不準的。 妳可以簡單做一個 html 的 textarea 看看 cols = 35 ,並不是每一行就是 35 個字的意思。

參考下面連結 http://www.w3schools.com/tags/atttextareacols.asp

對於 col 屬性的定義 Specifies the width of the text area (in average character width).

average character width 到底是多少呢? 這跟瀏覽器怎麼訂有關係,而且當妳縮放瀏覽器時又會不一樣。

這是個很複雜的問題,以上。

link publish delete flag offensive edit
0

answered 2013-09-09 08:21:03 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

updated 2013-09-09 08:21:50 +0800

Please refer to sample below:

<zk xmlns:w="client">
    <textbox rows="4" cols="35">
        <attribute w:name="bind_"><![CDATA[
            function (a, b, c) {
                this.$bind_(a, b, c);
                var inp = this.getInputNode(),
                    $inp = jq(inp),
                    wgt = this;
                $inp.bind('input', function () {
                    // has scrollbar
                    if ((inp.scrollHeight - inp.offsetHeight) > 10) {
                        $inp.val(''); // clear scrollbar
                        $inp.val(wgt._latestAllowedValue);
                    } else {
                        wgt._latestAllowedValue = $inp.val();
                    }
                });
            }
        ]]></attribute>
    </textbox>
</zk>
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-08-28 04:48:50 +0800

Seen: 27 times

Last updated: Sep 09 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More