启用\禁用基于文本框的按钮 [英] Enable\disable button based on textbox

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

问题描述

要基于在文本框中输入的文本来启用/禁用按钮,并且仅当在文本框中输入文本而不是空格时才启用按钮

To enable\disable button based on the text entered in the textbox and the button gets enabled only on entering the text in the textbox but not the spaces

推荐答案

function EnableDisableButton()
    {
       var txt = document.getElementById("<%=txtEmbedCode.ClientID %>");
       var btn = document.getElementById("<%=btnPreview.ClientID %>");
       if(txt.value.replace(/^\s+|\s+


/g," )== " ) { btn.disabled = true ; } 其他 { btn.disabled = false ; } }
/g, "")=="") { btn.disabled = true; } else { btn.disabled = false; } }




并调用此函数EnableDisableButton()




and call this function EnableDisableButton()


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

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