I have inherited some code that appears to use jqueryui 1.10.3 to incorporate a datepicker.
When I click the textbox to bring the datepicker up and choose a date, the format looks like
21.03.2020
However, if I click on the textbox again the format is
21/03/2020
The slash is the desired functionality. When the initial date is selected I want it to display as dd/mm/yyyy. How can I stop the date parts being separated by .
I have tried examining the jquery-ui-1.10.3 file to see if I can work out where the . separator is being applied but I haven't been able to come up with anything.
Somewhere in your web page or script section you should have code that looks like the code below.
This is where you can set your date time picker format. Look at the format date section.
$(document).ready(function () {
$("#<%= TextBoxName.ClientID %>").datetimepicker({
dayOfWeekStart: 1,
lang: 'en',
startDate: '<%= TextBoxName.Text %>',
step: 30,
formatTime: 'H:i',
formatDate: 'Y.m.d'
});
});
See more help here: jquery datetime picker
i have a few problems with the date-picker, especially regard the date format.
I need to make a date-format like that 'ddMMyyyy' without symbols like slash or minus.
this is my Markup
HTML
<input type="text" datepicker-popup="{{format}}" show-weeks="false" ng-model="Fromdate" show-button-bar='false'>
and that's my format in javascript
JS
$scope.format='ddMMyyyy';
is this the right way to make the format?
Because if i choose the date from the datepicker nothing seems to go wrong but if i type directly the text a errors happens.
the first four number were evaluated like year, so if i type '01022014' i aspect first february 2014 instead the date-picker evaluate 14 of no month (20 is not a month) of the 0102 year.
Second question, i'd like to put the option of the date Picker in the js file and not in the markup, for example:
HTML
<input type="text" datepicker-popup="{{format}}" ng-model="Fromdate" datepicker-options="options">
js
$scope.options={
show-weeks:"false"
show-button-bar:'false'
}
but in that way it seems doesn't work, what is thee right way to do that?
Use Uib-Datepicker
Js:
$scope.dateOptions = {
showWeeks: false,
format: 'ddMMyyyy'
};
HTML:
<uib-datepicker ng-model="selectedDate" datepicker-options="dateOptions" ng-required="true"></uib-datepicker>
I am using datebox plugin for jquery mobile http://dev.jtsage.com/jQM-DateBox2/unit/datebox.html
Everything works fine.
Here my question is how do i validating the individual year, month, date input fields by entering the numeric values in the specific fields ((ie) keydown/keypress..) without using of plus and minus buttons.
Thanks in advance...
This function checks if the input changed and logs the new date into the console.log:
$("div.ui-grid-b div input.ui-input-text").change(function() {
var parent = $(this).parent().parent();
console.log("date changed to: "
+parent.find("div.ui-block-a input.ui-input-text").val()+":"
+parent.find("div.ui-block-b input.ui-input-text").val()+":"
+parent.find("div.ui-block-c input.ui-input-text").val()
);
});
As a part of , I am using component with settled value of datePattern as follows:
<rich:calendar id="effectiveDate"
value="#{itemBean.effectiveDate}"
datePattern="EEEE, MM/dd/yyyy" />
So when I load the form, the existing effectiveDate from the requested itemBean is properly displayed in the text field.
Problems:
when clicking on calendar icon, the content of the text field will be gone. So if I didn't select anything from the calendar popup, then the text field remains empty.
when the date is selected it is displayed like that (for example):
EEEE, 11/19/2012
So the week day is not displayed properly.
Noticed that without specifying the week day (EEEE part of datePattern) none of mentioned above problems occurs.
Is there some specific way to display the week day after selecting?
I am on RichFaces 4.2.2.
Thanks!
As I think this is a known issue with <rich:calendar>. I don't know much about that.
However try this,
<rich:calendar id="effectiveDate" value="#{itemBean.effectiveDate}" onchanged="formatCalendarString(event, this);" datePattern="EEEE, MM/dd/yyyy" />
Within <head></head> tags put this.
<head>
<script>
function formatCalendarString(event, cal) {
var date = new Date(Date.parse(event.rich.component.getSelectedDate()));
var weekdays=new Array(7);
weekdays[0]='Sunday';
weekdays[1]='Monday';
weekdays[2]='Tuesday';
weekdays[3]='Wednesday';
weekdays[4]='Thursday';
weekdays[5]='Friday';
weekdays[6]='Saturday';
var day = weekdays[date.getDay()];
if(typeof(day) !== 'undefined') {
var formattedDate = (day + ', ') + event.rich.component.getSelectedDateString().substring(6);
cal.value = formattedDate;
}
}
</script>
</head>
How can I change the selected date of jquery Date picker dynamically on the fly?
I have say created a inline date picker.
Then after some time, I want to reflect a different date there without recreating the datepicker from the scratch.
I tried the setDate method, but did not work, and there is not much documentation in the doc.
There is another (extended?) plugin here, but I want to use the plugin which is shipped with jquery.ui.all.js.
What version of jQuery-UI are you using? I've tested the following with 1.6r6, 1.7 and 1.7.1 and it works:
//Set DatePicker to October 3, 2008
$('#dateselector').datepicker("setDate", new Date(2008,9,03) );
Check that the date you are trying to set it to lies within the allowed date range if the minDate or maxDate options are set.
This example shows of how to use default value in the dropdown calendar and value in the text box. It also shows how to set default value to previous date.
selectedDate is another variable that holds current selected date of the calendar control
var date = new Date();
date.setDate(date.getDate() - 1);
$("#datepicker").datepicker({
dateFormat: "yy-mm-dd",
defaultDate: date,
onSelect: function () {
selectedDate = $.datepicker.formatDate("yy-mm-dd", $(this).datepicker('getDate'));
}
});
$("#datepicker").datepicker("setDate", date);
Noted that for DatePicker by Keith Wood (http://keith-wood.name/datepickRef.html) the following works - note that the setting of the default date is last:
$('#datepicker').datepick({
minDate: 0,
maxDate: '+145D',
multiSelect: 7,
renderer: $.datepick.themeRollerRenderer,
***defaultDate: new Date('1 January 2008')***
});
$('.date-pick').datePicker().val(new Date()).trigger('change')
finally, that what i look for the last few hours! I need initiate changes, not just setup date in text field!
For some reason, in some cases I couldn't make the setDate work.
A workaround I found is to simply update the value attribute of the given input.
Of course the datepicker itself won't be updated but if what you just look for is to display the date, it works fine.
var date = new Date(2008,9,3);
$("#your-input").val(date.getMonth()+"/"+date.getDate()+"/"+date.getFullYear());
// Will display 9/3/2008 in your #your-input input
This is a old thread but I just want to give some information how I have used. If you want to set today date you can simply apply it like below.
$("#datepickerid").datepicker("setDate", "0");
If you want to set some days before/after the current date then use the symbol -/+ symbol of how many days you want like below.
$("#datepickerid").datepicker("setDate", "-7");
$("#datepickerid").datepicker("setDate", "+5");
This works for me:
$("#dateselector").datepicker("option", "defaultDate", new Date(2008,9,3));
please Find below one it helps me a lot to set data function
$('#datepicker').datepicker({dateFormat: 'yy-mm-dd'}).datepicker('setDate', '2010-07-25');
setDate only seems to be an issue with an inline datepicker used in jquery UI, the specific error is InternalError: too much recursion.
In Html you can add your input field with a date picker like this
<input class="form-control date-picker fromDates" id="myDate" type="text">
and then in java script, initialize your datepicker and set your value to the date like this,
$('.fromDates').datepicker({
maxDate: '0',
dateFormat: "dd/mm/yy",
changeYear: true,
changeMonth: true,
yearRange: "-100:+0"
});
var myDateVal = moment('${value}').format('DD/MM/YYYY');
$('#myDate').datepicker().datepicker('setDate', myDateVal );
(In here fromdate attribute shows the previous dates of the current date)
var dt = new Date();
var renewal = moment(dt).add(1,'year').format('YYYY-MM-DD');
// moment().add(number, period)
// moment().subtract(number, period)
// period : year, days, hours, months, week...
I had a lot of trouble with the setDate method as well. seems to only work in v1. What does seem to work however is using the dpSetSelected method:
$("#dateselector").dpSetSelected(new Date(2010, 0, 26).asString());
good luck!
or you can simply have
$('.date-pick').datePicker().val(new Date()).trigger('change')