Jill-Connie Lorentsen
Top achievements
Rank 1
Jill-Connie Lorentsen
asked on 18 Apr 2013, 09:20 AM
I have a scheduler with a customized advanced form. On this form I have a Boolean attribute control ResFlight, indicating whether the appointment is a flight, and a resource contol ResAirport holding the departing airport.
If the user checks the ResFlight checkbox I want the ResAirport to be required.
I would like to do this on the client, but I am a bit lost. I've tried using the asp validators, but I get an error saying that the ResAirport is "an invalid control to validate type"
Any ideas?
Regards, Jill-Connie Lorentsen
If the user checks the ResFlight checkbox I want the ResAirport to be required.
I would like to do this on the client, but I am a bit lost. I've tried using the asp validators, but I get an error saying that the ResAirport is "an invalid control to validate type"
Any ideas?
Regards, Jill-Connie Lorentsen
6 Answers, 1 is accepted
0
Hello Jill,
From here you can use either the serve or the client event to validate the control according to your requirements.
Hope this will be helpful
Regards,
Plamen
the Telerik team
Here is the mark up that makes the CustomValidator validate the resource RadCombobox:
<
asp:CustomValidator
runat
=
"server"
ID
=
"RequiredFieldValidator1"
ClientValidationFunction
=
"clientValidationFunction"
ControlToValidate
=
"ResRoom$ResourceValue"
ErrorMessage
=
"Select from combo"
OnServerValidate
=
"RequiredFieldValidator1_ServerValidate"
EnableClientScript
=
"true"
Display
=
"None"
CssClass
=
"rsValidatorMsg"
/>
From here you can use either the serve or the client event to validate the control according to your requirements.
Hope this will be helpful
Regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 25 Apr 2013, 10:40 AM
Thank you for your reply, but still some details are missing.
My markup is like this:
And the javascript:
The alert("flightCheckBox found") is displayed, but not alert("flightCheckBox.check"). I guess there is a syntax error somewhere, but I can't figure out where.
Regards, Jill-Connie Lorentsen
My markup is like this:
<
scheduler:BooleanAttributeControl
runat
=
"server"
ID
=
"ResFlight"
Type
=
"Flight"
Label
=
"Flight: "
Skin='<%# Owner.Skin %>' Checked='<%# Eval("Flight") %>' Value="false" />
<
scheduler:ResourceControl
ID
=
"ResAirport"
runat
=
"server"
Type
=
"Airport"
Required
=
"false"
Label
=
"Airport: "
Skin='<%# Owner.Skin %>' />
<
asp:CustomValidator
runat
=
"server"
ID
=
"AirportRequiredValidator"
ClientValidationFunction
=
"airportValidationFunction"
ValidateEmptyText
=
"true"
ControlToValidate
=
"ResAirport$ResourceValue"
ErrorMessage
=
"Choose airport"
EnableClientScript
=
"true"
Display
=
"None"
CssClass
=
"rsValidatorMsg"
/>
And the javascript:
function
airportValidationFunction(source, arguments) {
alert(
"airportValidationFunction"
);
arguments.IsValid =
true
;
var
flightCheckBox = $find($telerik.$(
"[id$='ResFlight']"
).attr(
"id"
));
alert(
"flightCheckBox found"
);
if
(flightCheckBox.checked ==
true
) {
alert(
"flightCheckBox.check"
);
if
(arguments.Value.length == 0) {
arguments.IsValid =
false
;
}
}
}
The alert("flightCheckBox found") is displayed, but not alert("flightCheckBox.check"). I guess there is a syntax error somewhere, but I can't figure out where.
Regards, Jill-Connie Lorentsen
0
Hello Jill,
Hope this will solve the issue.
All the best,
Plamen
the Telerik team
Here is the function that worked properly at my side:
function
airportValidationFunction(source, arguments) {
alert(
"airportValidationFunction"
);
arguments.IsValid =
true
;
var
flightCheckBox = $telerik.$(
[id$='ResFlight_AttributeValue']"
);
if
(flightCheckBox.attr(
"checked"
) ==
"checked"
) {
alert(
"flightCheckBox.check"
);
if
(arguments.Value.length == 0) {
arguments.IsValid =
false
;
}
}
}
Hope this will solve the issue.
All the best,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 30 Apr 2013, 09:23 AM
Thank you for your reply, but I am not quite there yet...
The alert("flightCheckBox.check") never shows.
If I add an alert(flightCheckBox.attr("checked")) the result is Undefined
Do I put the javascript in the AdvancedForm.ascx or in the default.aspx? I have all the scripts in the default.aspx
I am sorry, but I am not very familiar with javascript, so I find it very hard to debug.
Your help is appreciated!
Regards, Jill-Connie
The alert("flightCheckBox.check") never shows.
If I add an alert(flightCheckBox.attr("checked")) the result is Undefined
Do I put the javascript in the AdvancedForm.ascx or in the default.aspx? I have all the scripts in the default.aspx
I am sorry, but I am not very familiar with javascript, so I find it very hard to debug.
Your help is appreciated!
Regards, Jill-Connie
0
Hi Jill-Connie,
This code it concerning the advanced form so I will recommend you to put this javascript in the AdvancedForm.js(at the very bottom for example) I am attaching my sample test project that worked properly at my side.
(flightCheckBox.attr("checked") is supposed to return undefined when the Checkbox is not checked and "checked" otherwise.
Hope this will be helpful.
Regards,
Plamen
the Telerik team
This code it concerning the advanced form so I will recommend you to put this javascript in the AdvancedForm.js(at the very bottom for example) I am attaching my sample test project that worked properly at my side.
(flightCheckBox.attr("checked") is supposed to return undefined when the Checkbox is not checked and "checked" otherwise.
Hope this will be helpful.
Regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 02 May 2013, 09:04 AM
Thank you very much for your help!