Solved

JQuery Popup Calendar

Posted on 2011-02-22
2
773 Views
Last Modified: 2012-05-11
Hi I need to have the date formatted and written to the input field in UK format but not sure how to do this in JQuery.  The following must be wrong because it isn't putting the date in UK format so could someone please tell me what I'm doing wrong?

$(document).ready(function() {

$('#Date').datepicker({
                  onSelect: function(dateText, inst) {
                        var s = dateText.split("/");
                        $("#$YEAR$").val(s[2]);
                        $("#$DAY$").val(s[1]);
                        $("#$MONTH$").val(s[0]);
                        var ukDate = s[1]+s[0]+s[2];
                        //alert("UK Date is "+ukDate);
                        //$("#Date").val(ukDate);
                        dateFormat: 'dd-mm-yy';
                  }
            });
$('a[rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel

});
0
Comment
Question by:Lorna70
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Assisted Solution

by:rawinnlnx9
rawinnlnx9 earned 100 total points
ID: 34953544
Here you go: http://docs.jquery.com/UI/Datepicker look at the Localization section. This is what you want:

Localization
Datepicker provides support for localizing its content to cater for different languages and date formats. Each localization is contained within its own file with the language code appended to the name, e.g. jquery.ui.datepicker-fr.js for French. The desired localization file should be include after the main datepicker code. They add their settings to the set of available localizations and automatically apply them as defaults for all instances.

The $.datepicker.regional attribute holds an array of localizations, indexed by language code, with '' referring to the default (English). Each entry is an object with the following attributes: closeText, prevText, nextText, currentText, monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, weekHeader, dateFormat, firstDay, isRTL, showMonthAfterYear, and yearSuffix.
0
 
LVL 15

Accepted Solution

by:
Tomarse111 earned 150 total points
ID: 34953810
Try the attached code:
$("#Date").datepicker()
$("#Date").datepicker('option', {dateFormat: 'dd/mm/yy'});

Open in new window

0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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)

688 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