Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How check if jQuery datepicker is empty?

I have a date picker empty, but I do not know how to check if is empty (not validated or not)

like image 461
rtacconi Avatar asked Nov 05 '10 20:11

rtacconi


1 Answers

You can check the value of the input using .val(), like this:

if($("#fieldID").val() == "") {
  alert("no date selected");
}

Or for inline datepickers and such as well, use getDate which returns null if there's nothing selected:

if($("#fieldID").datepicker("getDate") === null) {
  alert("no date selected");
}
like image 197
Nick Craver Avatar answered Sep 21 '22 04:09

Nick Craver