Solved

JQuery Popup Calendar

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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…

815 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

12 Experts available now in Live!

Get 1:1 Help Now