在多行文本框中输入密钥 [英] Enter key in Multiline textbox

查看:62
本文介绍了在多行文本框中输入密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在我的页面上禁用了Enter键。但我需要为多行文本框启用输入键。因此,对于Multiline文本框,我编写了以下javascript代码。但是当我按下文本中间的ENTER键时(我的意思是,写了一行文字,我想把文本行分成两行。),当我按下ENTER键时,它会在最后添加一个新行。但我需要在中间(我保持光标并按下回车键)。



Hi All,

I disabled the Enter Key on my page. But i need to make enable the enter key only for Multiline textboxes. So that for Multiline textboxes i wrote the following javascript code. But when i press ENTER key in middle of the text (I mean, wrote a line of text and i want to break the line of text into two lines.), When i press ENTER it is adding a new line at the end. but i need in the middle(where i kept the cursor and pressed the enter key).

function EnterEvent(e, ctl) {

            var keycode = (e.keyCode ? e.keyCode : e.which);
            if (keycode == 13 ) {
                ctl.value = ctl.value + '\n';
            }

        }

推荐答案

在哪里编写代码以禁用Enter键那里放一个检查排除textarea控件。在这种情况下,无需编写上述脚本。概念是允许仅输入textarea。
Where you written code to disable Enter key there put a checking to exclude textarea controls. No need to write above script in that case. The concept is allow enter for textarea only.


只检查活动控件是否为多行文本框并启用它。

Just Simple
just check if active control is multiline textbox and enable it.
Just Simple


这篇关于在多行文本框中输入密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆