使用JQuery验证文本框 [英] Validate a textbox using JQuery
本文介绍了使用JQuery验证文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有TextBox和一个按钮
I have TextBox and a Button
首先按钮处于禁用位置
当用户开始在文本框中键入文本时
按钮应该启用
first the button is in disabled position When the user starts typing the text in textbox the button should be enabled
我如何使用JQuery或Java Script实现这一目标
How can i achieve this using JQuery or Java Script
推荐答案
你也可以试试这个
<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验证文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文