根据文本框条目启用和禁用按钮 [英] Enabling and disabling button based on textbox entry

查看:60
本文介绍了根据文本框条目启用和禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是EXT-JS的新手。

表格中有一个textfeild和按钮。默认情况下,该按钮是禁用的。当用户输入任何值到文本框时,按钮将启用,否则按钮将被禁用。如果有人知道如何使用EXt-JS代码,请提供帮助。

解决方案

对于常规JavaScript,可以使用以下内容:



即使对于文本框也是onkeyup(我碰巧喜欢按键),添加'onchange'也可以在剪切和粘贴的情况下使用

ID对于你的按钮



在onkeyup / onchange事件的处理程序中,使用DOM根据其内容启用/禁用按钮(例如通过 .length )。就个人而言,我总是在从内部字符串副本中修剪空白区域后测试内容,以确保框中确实有一个条目。



一个并行示例:

http://www.w3schools.com/jsref/prop_pushbutton_disabled.asp [ ^ ]



  document  .getElementById(   theButtonID)。disabled =  false ; 


Hi,
i am new to EXT-JS.
i have one textfeild and button in the form. By default the button is disable. When ever user enter any value to textbox then button will enable otherwise button will be disabled. please help if any one know how to handle with EXt-JS code.

解决方案

For Regular JavaScript, one would have the following:

An onkeyup even for the textbox (I happen to like key-up), adding an 'onchange' is also OK in case of a cut-and pasted
An ID for your button

In the handler for the onkeyup/onchange events, use DOM to enable/disable button based upon its content (such as via .length). Personally, I always test for content after trimming white-space from a copy of the string internal to be sure there's really an entry in the box.

A parallel example:
http://www.w3schools.com/jsref/prop_pushbutton_disabled.asp[^]

document.getElementById("theButtonID").disabled=false;


这篇关于根据文本框条目启用和禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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