Solved

JQuery Popup Calendar

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…

738 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