I am checking the Liferay Site for Alloy UI date picker.
The problem in the given example is that there is no select option. If the DOB of my user is in 70's then the user has to click back button multiple times.
This is not a happy scenario for the user. How can I edit my AUI javascript to something like month and year option given by jquery here
I'm assuming that you are using AlloyUI 1.5 here, and so I would recommend using the DatePickerSelect component but hiding the select elements that you don't need with display: none;. Assuming that you only want a year dropdown, you could hide both the month and day dropdowns. I've created a runnable snippet example here:
AUI().use('aui-datepicker', function (A) {
var datePicker = new A.DatePickerSelect({
dayNode: '#day',
monthNode: '#month',
yearNode: '#year',
calendar: {
dateFormat: '%m/%d/%Y'
},
render: true
});
// Working around the fact that the calendar does not get updated
// when a new year is selected:
var yearNode = A.one('#year');
yearNode.on('change', function(event) {
datePicker.calendar.set('currentYear', yearNode.get('value'));
var date = datePicker.calendar.date;
datePicker.calendar.clear();
datePicker.calendar.date = date;
});
});
<script src="http://cdn.alloyui.com/1.5.1/aui/aui-min.js"></script>
<link href="http://cdn.alloyui.com/1.5.1/aui-skin-classic/css/aui-skin-classic-all-min.css" rel="stylesheet">
<div id="datePicker">
<select id="month" style="display: none;">
<option></option>
</select>
<select id="day" style="display: none;">
<option></option>
</select>
<select id="year">
<option></option>
</select>
</div>
AUI Element:
<aui:input name="dateOfBirth" cssClass="dob" id="dateOfBirth" title="Date Of Birth" placeholder="dd/mm/yyyy" readonly="true" >
Script:
$(".dob").datepicker({ dateFormat: "dd/mm/yy",minDate: new Date(), changeYear: true,changeMonth: true,yearRange: "-0:+10y", onClose: function(date, datepicker) {$(".dob").focus(); }});
Related
I use a text input to show the date from Keith Wood datepicker jq. I'm using ('ummalqura', 'ar') as the type of date.
so far so good.
The problem is that I want to populate another text input with the equivilant date in ('gregorian', 'en').
in another word, one click on the calendar to genrate two different set of dates, one in (ummalqura) and the other in (gregorian).
any help will be appreciated.
here is the html code:
<div class="container ">
ummalqura date type: <input id="ah" class="form-control" type="text" name="datePicker">
<br>
gregorian date type: <input type="text" id="ad" >
</div>
and here is the js to the calendar datepicker in the first text input:
<script>
$("#ah").calendarsPicker({
calendar:
$.calendars.instance('ummalqura', 'ar'),
startDate: '0d',
minDate: 0,
onSelect: function (dates) {
$(this).trigger('change');
}
});
</script>
I wan't datetimepicker to show only rounded hours and disable minutes selection. So user will be able to pick only hours, like 02:00. However I can't achieve this simple task. Here is my code (in a Laravel view):
$("#date_from").datetimepicker({
format: 'yyyy-mm-dd hh:00',
startDate: "{{date('Y-m-d')}}",
minuteStepping: 60,
autoclose: true }).on('hide', function(e) {
$("#date_to").datetimepicker(
"setStartDate", new Date($('#date_from').val())
)....
I've tried steps: 60, stepping:60, minView: 1 and others.
Still I'm getting this
Here is one example for you, i think it will help you.
jsfiddle.net/tmk0293z/7/
There is changedate event bind with a function and changes the another startdate of other field.
Thanks,
Nishit Zinzuvadiya
Here is the actual code
(HTML):
<div class="input-append date form_datetime" id="first">
<input type="text" value="" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
<div class="input-append date form_datetime" id="second">
<input type="text" value="" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
<span id="selected"></span>
JS:
$(".form_datetime").datetimepicker({
format: "dd MM yyyy - hh:ii",
minView:1,
autoclose:true
});
$("#first").datetimepicker().on("changeDate", function(e){
var first = new Date(e.date.setMinutes(0));
first.setHours(first.getHours()+first.getTimezoneOffset()/60); //timezone correction
$("#second").datetimepicker('setStartDate', first);
//other = $("#first").find("input").val();
//$("#second").datetimepicker('setStartDate', other); //works also
});
see the option viewMode and format
https://eonasdan.github.io/bootstrap-datetimepicker/Options/
try using step: 60 not steps
please check this link also :click here
i've got a probleme with my date picker. I need to custom this datepicker but when i try to custom them it doesn't work.
Example:
I have this html code:
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input type="text" class="form-control" data-target="#job-date_start" name="date_start" title="" id="datestart" class="xlarge required" readonly>
<input type="hidden" id="job-date_start" value="" name="job[date_start]" />
</div>
And on javascript i try that:
$('#datestart').datepicker( {
onSelect: function(date) {
alert(date);
},
});
And my problem is, when i click on a date in my datepicker the console.log(test) don't appear.
Thanks you
Inlcude jquery and jquery ui libraries and then on document ready add your code http://jsfiddle.net/m443no17/
$(document).ready(function () {
$('#datestart').datepicker({
onSelect: function (date) {
alert(date);
},
});
});
Ofcourse , it will work the way you wrote . But , is not needed if you are having only one helper.
$('#datestart').datepicker( {
onSelect: function(date) {
alert(date);
}
});
Hope you have imported all the libraries required for datepicker and ofcourse jQuery proper version.
FYI :- Your DOM should be ready before you are executing this script
I have a select drop down that activates two datepicker input field depending on what is selected. When one field is selected, I would like to fill in the value of today's date plus one year. However, when I select that, I get this: Tue Aug 11 2015 00:00:00 GMT-0400 (Eastern Daylight Time). I would like to have the date as: mm/dd/yyyy.
I have setup a fiddle. http://jsfiddle.net/mwoods98/aku8ytju/
Updated fiddle
Here is a look at the code:
$(document).ready(function() {
$('#getHoldStatus').change(function()
{
var selected_item = $(this).val()
if(selected_item == "3"){
$('#datepicker').val("").removeClass('invisible');
$('#datepicker2').val("").removeClass('invisible');
var date = new Date("8/11/2014");
var date3 = new Date("8/11/2015");
$('#datepicker2').val(date3);
var newDate = new Date(date3.getFullYear(), date3.getMonth(), date3.getDate()+1);
$('#datepicker2').datepicker({ dateFormat: "mm/dd/yyyy" });
}
else if(selected_item == "2") {
$('#datepicker').val("").removeClass('invisible');
$('#datepicker2').val(selected_item).addClass('invisible');
$("#datepicker2").val('0');
}
else
{
$('#datepicker').val(selected_item).addClass('invisible');
$('#datepicker2').val(selected_item).addClass('invisible');
$("#datepicker").val('');
$("#datepicker2").val('');
}
}
);
// put all your jQuery goodness in here.
});
I am manually setting the date here for now but I can't seem to get it formatted properly.
<label class="control-label" for="getHoldStatus">
Hold Status
</label>
<div class="controls">
<select id="getHoldStatus" name="getHoldStatus">
<option value=""></option>
<option value="1" >None</option>
<option value="3" >On Hold until Candidate Available</option>
<option value="2" >On Hold until Position Available</option>
</select>
</div>
<label class="control-label" for="input08">
Hold Start Date
</label>
<div class="controls">
<script>
$(function() {
$( "#datepicker" ).datepicker({autoclose: true, todayHighlight: true, orientation: "bottom right"});
});
</script>
<div><input type="text" id="datepicker" value="" name="fdfHoldStartDate" class="invisible" /></div>
</div>
<label class="control-label" for="input09">
Hold End Date
</label>
<div class="controls">
<script>
$(function() {
$( "#datepicker2" ).datepicker({format: "mm/dd/yyyy", autoclose: true, todayHighlight: true});
});
</script>
<div><input type="text" id="datepicker2" value="" name="fdfHoldEndDate" class="invisible" /></div>
</div>
UPDATE: For some reason, the fiddle did not update. I have confirmed it and now the source appears relevant to the question I was asking. You can see how the date is being formatted when a selection is made.
Look at this: Bootstrap 3 datepicker - code generator
<input type="text" type="text" id="date1">
$('#date1').datepicker({
format: "mm-dd-yyyy"
});
Use the format instead of formatDate:
$('#datepicker2').datepicker({ format: "mm/dd/yyyy" });
The check in/check out example should be useful: Datepicker for Bootstrap
I have two input fields containing a class that triggers a datepicker to open. Both work fine independently, i.e when I click on one or the other but I want for both datepickers to open when either input field is clicked.
Here is the script part of the code
$(document).ready(function() {
$( ".datefields" ).datepicker({ dateFormat: 'dd/mm/yy',numberOfMonths: 1, yearRange: "2012:2014", changeYear: true, changeMonth: true});
and this is the html
<div id="quoteformcollection">
<h1>Collection</h1>
<input type"text" class="startTbl locationfields" id="AutoLocStart" value="Please Type a Collection Location"onclick="clearVal(this);"/>
<input type="hidden" id="DepotStart" value=""/></td>
<input type="text" class="datefields" id="collectiondate" value="21/05/2012"/>
<input type"text" class="timefields" value="12:00" />
</div>
<div id="quoteformreturn">
<h1>Return</h1>
<input type"text" class="locationfields" value="Enter the city or location for return" />
<input type"text" id="returndate" class="datefields" value="21/05/2012" />
<input type"text" class="timefields" value="12:00" />
</div>
I have tried looking for an answer myself but am quite new to jquery and struggling a bit so any help would be much appreciated.
I would also like for whatever value is selected in the first datepicker, for the default date in the second to be incremented by x number of days, which again I am not sure of the best way to go about it.
Any advice would be hugely appreciated!
Try this code for instance to link the two datapickers:
$('#collectiondate').datepicker({
dateFormat: "#",
onSelect: function(dateText, inst) {
var dateText = eval(dateText);
var min = new Date();
min.setTime(dateText);
$('#end').datepicker('option', 'minDate', min);
}
});
$('#returndate').datepicker({
dateFormat: "#",
});
I think you'd have to use the calendar 'inline' and manage how it's popped up yourself through jQuery / Javascript. You need to point the cal to a div tag to use it inline.
http://jqueryui.com/demos/datepicker/#inline