Go Premium for a chance to win a PS4. Enter to Win


jquery datepicker sending current date if input empty

Posted on 2010-08-26
Medium Priority
Last Modified: 2012-05-10
can anyone tell me why datepicker submits the current date if the input field is empty? this date field is not a compulsory field and can be used at the users discretion. many thanks.
Question by:peter_coop
  • 2
LVL 15

Accepted Solution

dirknibleck earned 1000 total points
ID: 33537853
I've never experienced this. Are you sure that the page itself is submitting the current date?

Is your server side PHP? If you use code like: date('Y/m/d', strtotime($_POST['date'])) and $_POST['date'] is blank, I believe strtotime will calculate the current date at the server...

Author Comment

ID: 33540086
thanks for reply. this is the php code:

$date_parts = explode("/",$_POST['datepicker']);
$newDate = $date_parts[2]  . "-" . $date_parts[1] . "-" . $date_parts[0];
$datepicker = date('Y/m/d', strtotime($newDate));

Author Closing Comment

ID: 33541800
thank you

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question