在点击提交按钮之前,如果选择的日期小于客户端的当前日期,我正在尝试添加TextBox ID =“tbComment”。
哪种方式更适合它?我尝试过javascript方式,但我不知道为什么但页面无法加载。
我知道文本框中存在“onTextChanged”事件,我们可以调用javascript,但是当选择的日期小于客户端的当前日期时,如何实现它来添加html?
<table class="sidemenu" id="BudgetDetailsTable" align="left" border="0" runat="server"
width="100%">
<tr>
<td width="20%">
Project Period Start Date:
</td>
<td width="80%">
<asp:TextBox ID="txtFromDate" title="Click to select date" Style="cursor: pointer"
runat="server" CssClass="textboxunderline" EnableViewState="true" TabIndex="1"></asp:TextBox><asp:RequiredFieldValidator
ID="rfvFromDate" runat="server" ErrorMessage="<br /> - Please provide Start Date."
ControlToValidate="txtFromDate">*</asp:RequiredFieldValidator><asp:CompareValidator
ID="cvFromDate" runat="server" ErrorMessage="<br /> - Please provide valid From date. From date should be before End date."
ControlToValidate="txtFromDate" Display="dynamic" Type="Date" Operator="LessThanEqual"
ControlToCompare="txtEndDate">*
</asp:CompareValidator>
<asp:CustomValidator ID="cvBeforeDate" runat="server" ErrorMessage="<br /> - Please provide a reason to for adding a sheet having start date before today's date."
OnServerValidate="cvCheck_StartDate">* </asp:CustomValidator>
</td>
</tr>
<tr>
<td width="20%">
Project Period End Date:
</td>
<td width="80%">
<asp:TextBox ID="txtEndDate" title="Click to select date" Style="cursor: pointer"
runat="server" CssClass="textboxunderline" EnableViewState="true" TabIndex="2"></asp:TextBox><asp:RequiredFieldValidator
ID="rfvEndDate" runat="server" ErrorMessage=" <br /> - Please provide End Date."
ControlToValidate="txtEndDate">* </asp:RequiredFieldValidator><asp:CompareValidator
ID="cvEndDate" runat="server" ErrorMessage="<br /> - Please provide valid End date. End date should be larger than From date."
ControlToValidate="txtEndDate" Display="dynamic" Type="Date" Operator="GreaterThanEqual"
ControlToCompare="txtFromDate">*
</asp:CompareValidator>
<asp:CustomValidator ID="cvDateMonth" runat="server" ErrorMessage="<br /> - Please provide start day and month different to end day and month."
ClientValidationFunction="cvDateMonth_ServerValidate">*</asp:CustomValidator>
</td>
</tr>
<tr>
<td width="20%" >
<asp:Label ID="Reason" CssClass="sidemenu" runat="server" Visible="False">Reason:</asp:Label>
</td>
<td width="80%" >
<asp:TextBox ID="tbComment" runat="server" Visible="False" TabIndex="3"
CausesValidation="false" Width="646px" Enabled="False"></asp:TextBox><asp:RequiredFieldValidator
ID="rfvReason" runat="server" CssClass="requiredStar" ErrorMessage="<br /> - Please provide a reason to submit a proposal who's start date is before Today's date."
ControlToValidate="tbComment">* </asp:RequiredFieldValidator>
</td>
</tr>
答案 0 :(得分:0)
您可以使用(element).innerHTML直接修改元素的源代码。这不应该给你一个错误,但也许其他人有一个更高级别的方法?