0

如果在点击提交按钮之前选择的日期小于客户端的当前日期,我正在尝试添加 TextBox ID="tbComment"。

哪种方式会更好?我尝试过使用 javascript 方式,但我不知道为什么,但页面无法加载。

I know there is "onTextChanged" event for a textbox when fired we can call a javascript, but how does one implement it to add html when the date selected is less than the current date on the client side?

<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>
4

1 回答 1

0

您可以使用 (element).innerHTML 直接修改元素的源代码。这不应该给你一个错误,但也许其他人有更高级的方法?

于 2012-07-17T19:47:33.893 回答