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

Required Field

3 Answers 83 Views
Slider
This is a migrated thread and some comments may be shown as answers.
richard
Top achievements
Rank 1
richard asked on 12 Feb 2009, 06:05 PM
Is it possible to make the slider a required field? It has CausesValidation, but nothing seems to be able to validate it.

Ideally i would like no glider or value to be associated with it (completely blank), until a choice is made.

thanks,

3 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 15 Feb 2009, 02:27 PM
Hello Richard,
I am not quite sure how you expect the RadSlider to behave, because it is, by definition, a required field. You define a range of values, from which the user can select, and the slider can accept only values from this range. You determine its initial value, which again is from that range. That is why, the slider always has a valid value.

In case you would like have a slider with values [0, 10] and you would like to make value 0 incorrect, you would have to define a custom validator with ControlToValidate property set to "". For example:
<script type="text/javascript"
function ClientValidationFunction(source, clientside_arguments) 
    var slider = $find('<%= RadSlider1.ClientID %>'); 
    if(slider.get_value() == 0)  
    { 
        clientside_arguments.IsValid=false
    } 
    else 
    { 
        clientside_arguments.IsValid=true
    } 
</script> 
<telerik:RadSlider ID="RadSlider1" runat="server" MinimumValue="0" MaximumValue="10"
</telerik:RadSlider> 
<asp:CustomValidator ID="CustomValidator1" runat="server"  
    ControlToValidate=""  
    ClientValidationFunction="ClientValidationFunction" 
    ErrorMessage="Error" Display="Dynamic"
</asp:CustomValidator> 


Regards,
Tsvetie
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
richard
Top achievements
Rank 1
answered on 16 Feb 2009, 02:35 PM
Thank you for the insite into the cutom validator. I know that will work nad did not think about using that.

Ideally, we would still like to have it default to nothing and have that as a valid choice. The would cause less stuff displayed on the page and would be more visually telling of the status.  for example, a survey question:
<telerik:RadSlider ID="RadSlider_Dependability" runat="server" Height="50px" Width="640px" ItemType="Item" 
                        MaximumValue="5" MinimumValue="0" TrackPosition="TopLeft" Value="-1" CausesValidation="false">  
                        <Items> 
                            <telerik:RadSliderItem runat="server" Text="Not at all Satisfied" Value="1" ToolTip="Not at all Satisfied" /> 
                            <telerik:RadSliderItem runat="server" Text="Slightly Satisfied" Value="2" ToolTip="Slightly Satisfied" /> 
                            <telerik:RadSliderItem runat="server" Text="Somewhat Satisfied" Value="3" ToolTip="Somewhat Satisfied" /> 
                            <telerik:RadSliderItem runat="server" Text="Very Satisfied" Value="4" ToolTip="Very Satisfied" /> 
                            <telerik:RadSliderItem runat="server" Text="Completely Satisfied" Value="5" ToolTip="Completely Satisfied" /> 
                        </Items> 
                    </telerik:RadSlider> 
I understand that this slider would always be valid, but it would be nice for the user to know visually that they have not selected anything for this question very quickyly. Without this feature, the survey looks as if the user did some work and they are done.

Anyway, thanks for help on the validator. That will allow me to finish this thing up.
0
Tsvetie
Telerik team
answered on 17 Feb 2009, 04:48 PM
Hi Richard,
I do understand what are trying to achieve. What I do not understand, is how you expect the RadSlider to look when you have Value="null". In case you would like:
  1. the dragHandle to be hidden
  2. the selection to be hidden
  3. when the user clicks on an item, the dragHandle and the selection to appear
, I cannot agree with you that such slider would visually "tell" the user that he/she has to select a value by dragging something that is, at this point, invisible.

You can however, use the client-side API of the RadSlider to achieve this. In case you decide to implement this approach and have problems, please send me your code and I will do my best to help you.

The contradiction in this case comes from the fact that a slider control should at any point in time, "point" to the currently selected item. And in the definition of the RadSlider that you have provided, there is no "null" item defined. However, in case you define such an item, it becomes a valid value.

Regards,
Tsvetie
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Slider
Asked by
richard
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
richard
Top achievements
Rank 1
Share this question
or