0

我在一个带有水印的文本框中有一个必填字段验证器。我正在使用 Ajax Toolkit ValidatorCalloutExtender。用户仍然可以单击提交按钮而无需进行任何验证。我在网上搜索过,但找不到有用的信息。我不确定我在这里缺少什么。

 <EditItemTemplate>
                            <asp:TextBox ID="TextBox6" runat="server" Width="403px"
                                Text='<%# Bind("Email") %>'></asp:TextBox>

                            <asp:RequiredFieldValidator ID="RequiredFieldEmail" runat="server" 
                            ErrorMessage="*** This is a required field ***" ControlToValidate="TextBox6" Display="None" 
                                Font-Bold="True" ForeColor="#FF3300"></asp:RequiredFieldValidator>
                                <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtenderEmail" runat="server" TargetControlID="RequiredFieldEmail" HighlightCssClass="validatorCalloutHighlight">
                            </ajaxToolkit:ValidatorCalloutExtender>

                               <ajaxToolkit:TextBoxWatermarkExtender ID="AuthorEmail_TextBoxWatermarkExtender" runat="server"
                                    Enabled="True" WatermarkText="<<Type the first 4 letters of the first name to autopopulate>>"
                                    TargetControlID="TextBox6">
                                </ajaxToolkit:TextBoxWatermarkExtender>


                                <ajaxToolkit:AutoCompleteExtender ID="autoComplete00" runat="server" EnableCaching="true"
                                    BehaviorID="AutoCompleteExa" MinimumPrefixLength="3" TargetControlID="TextBox6"
                                    ServicePath="../AutoComplete.asmx" ServiceMethod="GetCompletionList" CompletionInterval="1000"
                                    CompletionSetCount="10" CompletionListCssClass="autocomplete_completionListElement"
                                    CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
                                    DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true">
                                </ajaxToolkit:AutoCompleteExtender>
                        </EditItemTemplate>
4

1 回答 1

1

将RequiredFieldValidator 的InitialValue 设置为WatermarkText。修改你的 requiredfieldvalidator 的标记,如下所示,看看它是否有帮助。

<asp:RequiredFieldValidator ID="RequiredFieldEmail" runat="server" ErrorMessage="*** This is a required field ***" ControlToValidate="TextBox6" Display="None" InitialValue="<<Type the first 4 letters of the first name to autopopulate>>" Font-Bold="True" ForeColor="#FF3300"></asp:RequiredFieldValidator>
于 2012-11-26T00:07:32.897 回答