Search code examples
angularjs-directiverequired

How to make a angucomplete-alt tag 'required' in a form


I am using angucomplete-alt in many places of my web application (in forms), but i cant make the autocomplete fields as a 'required' field, even thought i've used the 'field-required' attribute.

angucomplete-alt#sectorSuggested(field-required= true,placeholder='Search sectors', local-data='sectors', selected-object='onSectorSelected', search-fields='Sector', pause='300', minlength='1', title-field='Sector',input-class="form-control form-control-small", name='sector')

how do i make it required field, please help :)


Solution

  • Going off of the documentation and examples I can see here, it looks like the attribute should be

    field-required="true"

    In the above example, his element looks like this:

    <div angucomplete-alt="" id="ex8" placeholder="Search countries" pause="100" selected-object="countrySelected8" local-data="countries" search-fields="name" title-field="name" minlength="1" input-class="form-control form-control-small" match-class="highlight" field-required="true" class="ng-isolate-scope">
    

    Additionally, if you have many required fields, his documentation states:

    Set custom class name for required. Unique class names need to be set when you have multiple directives to validate

    You can do this, using the field-required-class attribute.

    Taken from here