Multiple calendars 1 page validation

6 posts, 0 answers
  1. Jomey
    Jomey avatar
    60 posts
    Member since:
    Jan 2008

    Posted 29 Mar 2008 Link to this post

    when u type in "ddddddddddd" and hit submit both calendars error out.  Only the one where u typed in "dddddddddddd" should error out.

    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
    <script type="text/javascript">
    var invalidInput = false;
    function OnDateSelected(sender, args)
    {
    invalidInput = false;
    }

    function OnError(sender, args)
    {
    invalidInput = true;
    }

    function CustomValidate(sender, args)
    {
    if (invalidInput)
    args.IsValid = false;
    }        
    </script>


    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="RadDatePicker1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
    <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="CustomValidate"
    ErrorMessage="Date must be valid (mm/dd/yyy)" />
    <telerik:RadDatePicker ID="RadDatePicker1" Runat="server">
    <ClientEvents OnDateSelected="OnDateSelected" />
    <DateInput ID="DateInput1" runat="server" CausesValidation="true" ClientEvents-OnError="OnError"></DateInput>
    </telerik:RadDatePicker>
    <br />

    <asp:CustomValidator ID="CustomValidator2" runat="server" ClientValidationFunction="CustomValidate"
    ErrorMessage="Date must be valid (mm/dd/yyy)" />
    <telerik:RadDatePicker ID="RadDatePicker2" Runat="server">
    <ClientEvents OnDateSelected="OnDateSelected" />
    <DateInput ID="DateInput2" runat="server" CausesValidation="true" ClientEvents-OnError="OnError"></DateInput>
    </telerik:RadDatePicker>


    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="true" ShowSummary="false" />
    <asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="true" />
    </div>
    </form>
    </body>
  2. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 01 Apr 2008 Link to this post

    Hi Jomey,

    You should either use the ControlToValidate property of the CustomValidators or define a second function eg. CustomValidate1 and set that as the ClientValidateFunction in the second custom validator. Currently both custom validators validate all controls and call the same function.

    Best wishes,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Jomey
    Jomey avatar
    60 posts
    Member since:
    Jan 2008

    Posted 01 Apr 2008 Link to this post

    When adding ControlToValidate on the customvalidator's.  The submit always posts even if there is an error.  So the box lights up red which is caught on the onerror event.  Then if you hit submit - the form posts.  It's not supposed to. 

    Is this a bug?
  4. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 02 Apr 2008 Link to this post

    Hi Jomey,

    I've not been able to reproduce the behavior you describe. Find attached a sample project - please run it as it is and let us know of the outcome.

    Best wishes,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Jomey
    Jomey avatar
    60 posts
    Member since:
    Jan 2008

    Posted 02 Apr 2008 Link to this post

    If you get rid of the requiredfieldvalidator - it exhibits the behavior that i described above.
  6. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 03 Apr 2008 Link to this post

    Hi Jomey,

    Indeed you're correct. I've modified the sample to observe the expected behavior for this scenario. Give it a spin and let us know if further help is needed.

    Regards,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top