0

I have a div which acts like a modal popup. Inside that, I need a validation for which I setup a custom validator. But the message doesn't get fired, though the alert box does.

My code:

                if ((oldFromTime <= newFromTime) && (oldToTime > newFromTime)) {
                 alert("Choose time ahead of the ones saved earlier.!");
                arguments.IsValid = false;

            }
            else {
                arguments.IsValid = true;

            }

And my custom validator

<asp:CustomValidator id="cboToTimeMins_CustomValidator" ControlToValidate="cboToTimeMins" ClientValidationFunction="validateTime" Display="static" ErrorMessage="Selected time range falls in the range of the ones saved earlier...! Choose another." runat="server" ValidationGroup="Timetable"/>

cboToTimeMins is my dropdown box, and I need to set the validation message based on the value selected from it. Is there something wrong in my code?

P.S. I am in need of only CLIENT SIDE validation.

4

2 回答 2

0

这是我的示例解决方案

                    <td class="normal">Price<span class="required">*</span></td>
                    <td class="normal" colspan="6">
                        <asp:TextBox ID="txtPrice" CssClass="text" Enabled="true" runat="server"  MaxLength="10" Width="100px" />
                         <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPrice"
                                    ErrorMessage="* Please Input Your Price" Display="Dynamic" ValidationGroup="hdrValidation"/>

                    </td>

你需要验证

 Page.Validate("hdrValidation")
        If Not Page.IsValid Then Exit Sub
于 2013-04-25T04:49:44.053 回答
0

这是我的解决方案。我删除了下拉菜单的自定义验证器并将其添加到按钮中。此外,我删除了 Javascript 函数中的警报消息。

于 2013-04-25T04:43:37.180 回答