0

I have a input where you can type in a URL. Now I also like to add a suggestion list to the input where you can select predefined URLs.

My attempt was to change from type=url to type=select and provide a datalist:

<input type=select list=servers required ng-model=server />
<datalist id=servers>
    <option label="Server example 1" value="https://www.google.de/"/>
</datalist>

But now I am missing the URL validation from angular. Is there a way to combine those two types? Or any other suggestion how I can do that?

Thanks in advance

3
  • 1
    This doesn't even make sense. First, URL "validation" is an HTML5/browser feature, not an angular feature. Second, there is no HTML type="select"; select boxes are a completely different element type, they are not an input. Commented Oct 20, 2017 at 6:19
  • Btw you have defined the attribute "list" on the input but you have to define the "id" attribute on the datalist tag. Just use type "text" on your input. Commented Oct 20, 2017 at 7:25
  • Thanks, the missing ID was just a copy mistake from my side. The list is shown. But I thought I also need to edit the type. but it indeed looks like I do not need to change the type... Commented Oct 20, 2017 at 7:27

1 Answer 1

1

the type "select" does not exist on input tag. To propose a suggestion maybe you can create an autocompletion system or just a select HTML tag with options.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.