1

I am currently trying to completely remove a datepicker element from the DOM, if the device being used doesn't have a touch screen. (.no-touch). And replace it with a select menu. Unfortunately my parsley validation is still showing from datepicker, even if I hide the element with pure CSS. I think I can use modernizr to do so. But I am having some difficulty getting it to work. Here is the code I have right now.

if (!Modernizr.inputtypes.date) { 
 $('html.no-touch .datepicker').datepicker({
  disabled: true  
 });
}
Spizzy
  • 11
  • 2

1 Answers1

0

If you are removing the element completely you will want to call destroy on the datepicker before you remove the element.

$('html.no-touch .datepicker').datepicker('destroy').remove();
Stuart
  • 201
  • 1
  • 11