Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accents in HTML5 datalist

In a form, I have a text input with a datalist. In the datalist, I have accented terms that won't appear in my text input. For example : If I type "a", terms with "ä" or "à" won't appear in suggestion...

The best would be the whole to be accent insensitive

Does anyone encounter that problem already ?

Thank you

like image 837
VeZoul Avatar asked Apr 24 '14 07:04

VeZoul


People also ask

Is Datalist tag in HTML5?

The datalist tag is introduced in HTML5. The <datalist> tag should be used with an <input< element that contains a "list" attribute. The value of "list" attribute is linked with the datalist id.

Can we style Datalist in HTML?

HTML5 <datalist> elements cannot be styled.

Can you style a Datalist?

Like select elements, the datalist element has very little flexibility in styling. You cannot style any of the suggested terms if that's what your question was asking. Browsers define their own styles for these elements.

How the Datalist tag can be used in HTML?

The <datalist> tag is used to provide an "autocomplete" feature for <input> elements. Users will see a drop-down list of pre-defined options as they input data.


1 Answers

One dirty way you can do this is by doing something likes this:

var noAccent = str.normalize( "NFD" ).replace( /[\u0300-\u036f]/g, "" );
if (str !== str) {// Add a duplicate entry without the accent}
like image 114
LaurentGoderre Avatar answered Sep 17 '22 14:09

LaurentGoderre