PDA

View Full Version : فعال کردن دکمه باتن در صورت پر بودن چند textbox



mariakhanom
دوشنبه 23 بهمن 1391, 18:02 عصر
سلام دوستان
من چندتا کست باکس دارم و یک دکمه ودر حالت عادی دکمه غیر فعال است.میخوام زمانی دکمه فعال بشه که همه ی تکست باکس ها مقدار داشته باشن.چطور میشه اینکارو کرد؟

ahmad156
دوشنبه 23 بهمن 1391, 18:49 عصر
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var state = 1;
$("#txt1").keyup(function () {
myfunc();
});
$("#txt2").keyup(function () {
myfunc();
});
$("#txt3").keyup(function () {
myfunc();
});

function myfunc() {
state = 1;
if ($("#txt1")[0].value == "" || $("#txt2")[0].value == "" || $("#txt3")[0].value == "") {
state = 0;
}
if (state == 1) {
$('#btn').attr("disabled", false);
}
else {
$('#btn').attr("disabled", true);
}
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:button runat="server" text="btn" clientidmode="Static" enabled="False" ID="btn"/>
<asp:textbox runat="server" id="txt1" clientidmode="Static">
</asp:textbox>
<asp:textbox runat="server" id="txt2" clientidmode="Static">
</asp:textbox>
<asp:textbox runat="server" id="txt3" clientidmode="Static">
</asp:textbox>
</div>
</form>
</body>
</html>