Solved

JQuery Popup Calendar

Posted on 2011-02-22
2
753 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

943 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now