Required Field

4 posts, 0 answers
  1. richard
    richard avatar
    9 posts
    Member since:
    Jul 2012

    Posted 12 Feb 2009 Link to this post

    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,
  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 15 Feb 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. richard
    richard avatar
    9 posts
    Member since:
    Jul 2012

    Posted 16 Feb 2009 Link to this post

    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:
    1 <telerik:RadSlider ID="RadSlider_Dependability" runat="server" Height="50px" Width="640px" ItemType="Item" 
    2                         MaximumValue="5" MinimumValue="0" TrackPosition="TopLeft" Value="-1" CausesValidation="false">  
    3                         <Items> 
    4                             <telerik:RadSliderItem runat="server" Text="Not at all Satisfied" Value="1" ToolTip="Not at all Satisfied" /> 
    5                             <telerik:RadSliderItem runat="server" Text="Slightly Satisfied" Value="2" ToolTip="Slightly Satisfied" /> 
    6                             <telerik:RadSliderItem runat="server" Text="Somewhat Satisfied" Value="3" ToolTip="Somewhat Satisfied" /> 
    7                             <telerik:RadSliderItem runat="server" Text="Very Satisfied" Value="4" ToolTip="Very Satisfied" /> 
    8                             <telerik:RadSliderItem runat="server" Text="Completely Satisfied" Value="5" ToolTip="Completely Satisfied" /> 
    9                         </Items> 
    10                     </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.
  5. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 17 Feb 2009 Link to this post

    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.
Back to Top