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

HTML5 Required

1 Answer 41 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Chance
Top achievements
Rank 1
Chance asked on 01 Aug 2019, 04:35 PM

Is there a way to get the Required validator in HTML5 to work with the RadAutoCompleteBox box?

I tried using JavaScript to add the required attribute to the '.._Input' control in the markup but it didn't work.

Here is my code:

      <div class="form-group">        
                   <telerik:RadAutoCompleteBox
                                                 ID="txtAddress"
                                                 Runat="server"
                                                 DataSourceID="dsAddressSearch"
                                                 DataTextField="search"
                                                 DataValueField="ID"
                                                 Filter="StartsWith"
                                                 InputType="Text"
                                                 ClientIDMode="Static"
                                                 Skin="Bootstrap" RenderMode="Auto" Width="90%" AllowCustomEntry="True"   >
                                                 <TextSettings SelectionMode="Single"   />
                                             </telerik:RadAutoCompleteBox>
                                            
            <div class="invalid-feedback">Address is required. </div>
        </div>

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 06 Aug 2019, 10:51 AM
Hi Chance,

I've managed to implement the HTML5 required validation using the following approach:

<script>
    function OnClientLoad(sender, args) {
        sender.get_inputElement().setAttribute("required", "required");
    }
</script>
<button>Submit</button>
<telerik:RadAutoCompleteBox
    OnClientLoad="OnClientLoad"
    ID="txtAddress"
    runat="server"
    DataSourceID="dsAddressSearch"
    DataTextField="search"
    DataValueField="ID"
    Filter="StartsWith"
    InputType="Text"
    ClientIDMode="Static"
    Skin="Bootstrap" RenderMode="Auto" Width="90%" AllowCustomEntry="True">
    <TextSettings SelectionMode="Single" />
</telerik:RadAutoCompleteBox>


Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoCompleteBox
Asked by
Chance
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or