-4

is it possible to check an input type date is set without a submit button. I.e if done through mobile browser there is a set button when you first click on the date input field is there a way to check that this "set" button was clicked and for desktop view you get the calendar when the user clicks on a date this would be the same button, is there a way to check this has been clicked without the submit button?

Image Example:

enter image description here

Normally I would just check using a submit button, something like this:

if (isset($_GET['date'])){
    $date = $_POST['dateValue'];
    if (empty($date)) {
        //if date is not set...
    }
    else{
        //if date is set...
    }
}

Thanks guys, been struggling with this for a while now.

Matt Hutch
  • 453
  • 1
  • 6
  • 20

1 Answers1

0

Why not let HTML handle it?

<input type ="date" required>

forms wont submit unless input type with required attribute is not empty

Lorence Hernandez
  • 1,189
  • 12
  • 23
  • Sorry I should have mentioned I wanted to make the page save the data entered, so that the user can change page and the date will still be there when they return. – Matt Hutch Nov 05 '16 at 16:30
  • isnt it saving automatically? try fill up the form then go to other page, when you press back the data is still there, not unless you refreshed the page. but if you want to also rememeber the data even the page is refreshed check this http://stackoverflow.com/questions/9308336/execute-function-before-refresh – Lorence Hernandez Nov 05 '16 at 16:40