This is a migrated thread and some comments may be shown as answers.

Multiple calendars 1 page validation

5 Answers 109 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jomey
Top achievements
Rank 1
Jomey asked on 29 Mar 2008, 05:38 PM
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>

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 01 Apr 2008, 01:28 PM
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
0
Jomey
Top achievements
Rank 1
answered on 01 Apr 2008, 04:36 PM
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?
0
Steve
Telerik team
answered on 02 Apr 2008, 01:57 PM
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
0
Jomey
Top achievements
Rank 1
answered on 02 Apr 2008, 05:17 PM
If you get rid of the requiredfieldvalidator - it exhibits the behavior that i described above.
0
Steve
Telerik team
answered on 03 Apr 2008, 11:50 AM
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
Tags
Calendar
Asked by
Jomey
Top achievements
Rank 1
Answers by
Steve
Telerik team
Jomey
Top achievements
Rank 1
Share this question
or