Solved

JQuery Popup Calendar

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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)

708 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

14 Experts available now in Live!

Get 1:1 Help Now