问题
I have a date picker empty, but I do not know how to check if is empty (not validated or not)
回答1:
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");
}
回答2:
I used something like this and it worked for me.
if($("#fieldID").val() == undefined) {
alert("no date selected");
}
来源:https://stackoverflow.com/questions/4109913/how-check-if-jquery-datepicker-is-empty