Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

get null when no date is selected #142

Open
like73 opened this issue Apr 19, 2018 · 2 comments
Open

get null when no date is selected #142

like73 opened this issue Apr 19, 2018 · 2 comments

Comments

@like73
Copy link

like73 commented Apr 19, 2018

How can I get null when no date is picked ?
Currently, the getDate method returns today's date when no date is picked.
Same when I clear the date by hiting backspace key...

@Gataquadrada
Copy link

Try this:

var picked = false;

$().on( 'pick.datepicker' , function(){
  picked = true;
});

$( '#my_button' ).click( function(){
  if( picked )
  {
    console.log( $().datepicker( 'getDate' ) );
  }
  else
  {
    console.log( 'PICK A DATE!' );
  }
} );

@chrislawes79
Copy link

I use $('[data-toggle="datepicker"]').datepicker().text() to check if the default text is displayed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants