HTML5 use for filter

HTML5 use for filter

mjdinsmoremjdinsmore Posts: 10Questions: 1Answers: 0
edited March 2013 in Bug reports
I am classifying this as a bug because it was something noticed/commented upon in the DataTables 1.8 release as being trivial (and it is) but it's still not fixed. It would be nice to have the HTML input type to be "search" instead of "text" for the filter. This would allow it to automatically have a clear button on supporting browsers. There was a comment from Allan saying how it'd be trivial to make the change with jQuery (see The only problem is that his recommendation does not work with jQuery. If you look at the jQuery code, you'll see:


// We can't allow the type property to be changed (since it causes problems in IE)
if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
throw "type property can't be changed";

This will prevent you from trying to dynamically changing the attribute type - e.g. $('#filter_input').attr('type', 'search'); . This will just give you the error "type property cannot be changed".

It would be nice to have this fixed. As bonus points, since you're in that area of code, why not also add a "placeholder" HTML5 element as well, and allow that text to be easily configurable by the user, but maybe default it with something like "Enter your text to filter" or something like that.


  • allanallan Posts: 61,066Questions: 1Answers: 9,956 Site admin
    Already in git: :-)

    Will be available in 1.10.

  • mjdinsmoremjdinsmore Posts: 10Questions: 1Answers: 0
    Awesome. Thanks!
This discussion has been closed.