回答
你可以用这个也
<input type='text' id='textbox'>
<input type="button" class="button-disabled" id="change" disabled="disabled" value="click">
$("#textbox").keyup(checkForm).focus(checkForm);
function checkForm()
{
if($("#textbox").val()=='')
{
$("#change").addClass("button-disabled").removeClass("button");
$("#change").attr("disabled","disabled");
}
else
{
$("#change").removeClass("button-disabled").addClass("button");
$("#change").removeAttr("disabled");
}
}
似乎你是jQuery的新手。我会说你从jQuery Tutorials开始,然后移动到jQuery Validate。如果您更喜欢开始的书籍,您可以拿起jQuery in Action的副本。
HTML:
<input type='text' id='textbox'>
<input type="button" id="mybutton" value="click me">
JS:
$(document).load(function() {
$('#mybutton').attr('disabled', 'disabled');
}
$('#textbox').change(function() {
$('#mybutton').removeAttr('disabled');
}
更新:关于使用jQuery的W/ASP.NET,请记住,ASP.NET输出标准的HTML一旦呈现页面时,所以上面的代码可以类似地工作,除非你需要找出由ASP.net生成的文本框的ID。请参阅本此链接作进一步的解释:
http://www.search-this.com/2009/08/06/using-jquery-with-asp-net-controls/
<input type='text' id='thetext' value=''>
<input type='button' disabled='disabled' id='thebutton' value='the button'>
$(document).ready(function(){
$('#thetext').change(function(){
$('#thebutton').removeAttr('disabled');
});
});
阅读上的jQuery的API:http://api.jquery.com/
我想做ASP控制 – user646751 2011-03-09 17:25:18
<input type='text' id='textbox'>
<input type="button" id="button'" value="click me">
$('#button').attr('disabled', 'disabled');
$('#textbox').change(function(){$('#button').removeAttr('disabled')});
<input type="text" id="myText">
<input type="submit" id="myButton" disabled="disable"/>
jQuery(function(){
jQuery('#myText').bind('keypress',function(e){
if((jQuery(e.target).val()+"").length>0)
{
jQuery('#myButton').removeAttr('disabled');
}
else
{
jQuery('#myButton').attr('disabled','disable');
}
});
});
if((jQuery(e.target).val()+“”)。length> 0)'可以简化为if(this.value.length> 0)'考虑到这将运行在文本输入上的每个按键上 – meouw 2011-03-09 08:35:38
我必须使用ASP COTROLS – user646751 2011-03-09 17:25:41
使用控件的clientID或将css类添加到控件,并将此“jQuery('#myText')”替换为“jQuery '.your_css_class_name')” – 2011-03-09 18:20:38
- 1. 验证使用jQuery验证
- 2. 验证使用jQuery
- 3. 验证使用jQuery
- 4. 验证使用jQuery
- 5. 验证使用jquery
- 6. 使用jQuery验证
- 7. 使用jquery验证
- 8. jQuery验证addMethod使用JQuery验证验证定制方法
- 9. 使用jQuery Labelify + jQuery验证
- 10. 条件验证使用jquery验证
- 11. 使用jquery验证验证码
- 12. 使用jQuery验证PHP验证码
- 13. 使用jQuery验证的日期验证
- 14. 使用jquery验证验证captcha
- 15. 如何使用jQuery验证验证recaptcha_tag?
- 16. 验证数组使用jQuery验证
- 17. 使用jquery验证码验证码
- 18. 使用jQuery和php验证验证码
- 19. 使用jQuery验证字段验证组
- 20. 应用使用jQuery验证
- 21. jQuery:使用验证查询
- 22. 验证使用javascript/jQuery的
- 23. 使用Jquery验证时间
- 24. 使用jquery验证表单
- 25. 使用jquery验证“div”
- 26. 使用jquery验证dropdownlist
- 27. 使用tinyMCE验证textarea - jquery
- 28. 验证码使用jQuery
- 29. 使用jQuery验证插件
- 30. Google recaptcha使用Jquery验证
我尝试认为这适用于HTML控件,但我有asp.net控件 – user646751 2011-03-09 19:03:00
我对我的帖子进行了详细说明,详细说明了如何使用jquery w/asp.net。希望有帮助 – 2011-03-10 04:41:57