I have the following code for my datepicker text box:
<!-- Setup Datepicker -->
<script type="text/javascript"><!--
$(function() {
$('input').filter('.datepicker').datepicker({
changeMonth: true,
changeYear: true,
showOn: 'button',
buttonImage: 'jquery/calendar.gif',
buttonImageOnly: true
});
});
--></script>
I would like to setup the year slide drop-down from 1910 to 2014.
I read the API but I´m new in coding and don´t understand and don´t know how to apply.
How can I do it?
What I have to put in this code for that?
How can I change the language from English to Spanish?
Here it is, working:
Add the option yearRange: '1910:2014'
$(function() {
$( "#datepicker" ).datepicker({changeMonth: true,changeYear: true,
yearRange: '1910:2014'});
});
<p>Date: <input type="text" id="datepicker" /></p>
UPDATE 1
$(function() {
$.datepicker.regional['es'] = {
closeText: 'Cerrar',
prevText: '<Ant',
nextText: 'Sig>',
currentText: 'Hoy',
monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
'Jul','Ago','Sep','Oct','Nov','Dic'],
dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'],
dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
weekHeader: 'Sm',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['es']);
//for year list
$( "#datepicker" ).datepicker({
changeMonth: true,
changeYear: true,
yearRange: '1910:2014'});
});
<p>Date: <input type="text" id="datepicker" /></p>
Related
Suppose I change the start date and click on End Date before render the start date. Then datepicker of End date will be close because of rendering of start date value. If you have any solution or any datepicker suggestion, please help me.
Blade File
<div class="col">
<label for="">Start Date <span class="text-danger">*</span></label>
<input type="text" name="start_date" wire:model.lazy='start_date'
class="form-control #error('start_date') is-invalid #enderror">
#error('start_date')
<small class="text-danger">{{ $message }}</small>
#enderror
</div>
<div class="col">
<label for="">End Date <span class="text-danger">*</span></label>
<input type="text" name="end_date" wire:model.lazy='end_date'
class="form-control #error('end_date') is-invalid #enderror">
#error('end_date')
<small class="text-danger">{{ $message }}</small>
#enderror
</div>
My Script Code for Datepicker
<script>
$('input[name=start_date]').datetimepicker({
format: "DD/MM/YYYY",
disabledDates: false,
useCurrent: false,
showClear: true,
showClose: true,
showTodayButton: true,
});
$('input[name=start_date]').on("dp.change", function(e) {
#this.set('start_date', e.target.value);
});
$('input[name=end_date]').datetimepicker({
format: "DD/MM/YYYY",
disabledDates: false,
useCurrent: false,
showClear: true,
showClose: true,
showTodayButton: true,
});
$('input[name=end_date]').on("dp.change", function(e) {
#this.set('end_date', e.target.value);
});
</script>
If I'm not misunderstand you question why you use "wire:model.lazy" ? "wire:model" remove .lazy might be fixed your problem?
I'm using the City search from the example https://community.algolia.com/places/examples.html#city-search
When you made selection, it only displays the City. How can I display it as City, State?
<input type="search" id="city" class="form-control" placeholder="In which city do you live?" />
<script src="https://cdn.jsdelivr.net/npm/places.js#1.17.1"></script>
<script>
(function() {
var placesAutocomplete = places({
appId: '<YOUR_PLACES_APP_ID>',
apiKey: '<YOUR_PLACES_API_KEY>',
container: document.querySelector('#city'),
templates: {
value: function(suggestion) {
return suggestion.name;
}
}
}).configure({
type: 'city',
aroundLatLngViaIP: false,
});
})();
</script>
I am using materializeCSS datepicker and I only want to select Year and Months
I tried this. Also how to format the date. I want to have it's representation as 2017-07-20
$('.datepicker').pickadate({
selectMonths: true, // Creates a dropdown to control month
selectYears: 15,
selectDays: false,
today: 'Today',
clear: 'Clear',
close: 'Ok',
closeOnSelect: false // Close upon selecting a date,
});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.0/css/materialize.min.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.0/js/materialize.min.js"></script>
<div class="input-field">
<input type="date" class="datepicker" name="date" id="date">
</div>
Try this code
$('.datepicker').pickadate({
selectMonths: true, // Creates a dropdown to control month
selectYears: 15,
disable: [true],//disable days
today: 'Today',
clear: 'Clear',
close: 'Ok',
closeOnSelect: false // Close upon selecting a date,
});
DEMO
$(function() {
$('input.month-mode').datetimepicker({
viewMode: 'months',
format: 'MM/YYYY',
showClose: true,
maxDate: current_month,
});
});
I want to add close text to it. by default it shows 'X', but I want to change it. Is it possible?
You can use icons option to define a custom css class for your icon and then you can write a css rule to customize close text as shown below:
$(function () {
var current_month = moment(); // just a sample value
$('#datetimepicker1').datetimepicker({
showClose: true,
viewMode: 'months',
format: 'MM/YYYY',
maxDate: current_month,
icons: {
close: 'closeText'
}
});
});
.closeText:before {
content: "Close";
}
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet"/>
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
One way to do this is to use the icon classes to a add a new class and then use css to add some content. Something like:
$(function() {
$('input.month-mode').datetimepicker({
viewMode: 'months',
format: 'MM/YYYY',
showClose: true,
maxDate: current_month,
icons: {
close: 'textclass1'
}
});
});
Css:
.textclass1::before {
content: "Close";
}
I want to use the JavaScript Alfresco.ObjectPicker component in order to have category picker into the file: dnd-upload.get.html.ftl
<div class="form-field inlineable">
<label >Catégories:</label>
<div class="object-finder inlineable" id="a_default_prop_cm_categories-cntrl">
<div class="current-values inlineable object-finder-items" id="b_default_prop_cm_categories-cntrl-currentValueDisplay"></div>
<input type="hidden" value="" name="prop_cm_categories" id="c_default_prop_cm_categories"/>
<div class="show-picker inlineable" id="d_default_prop_cm_categories-cntrl-itemGroupActions"><span class="yui-button yui-push-button" id="yui-gen7"><span class="first-child"><button type="button" tabindex="0" id="yui-gen7-button" >Sélectionner</button></span></span></div>
<script type="text/javascript"> //<![CDATA[
(function(){
var picker = new Alfresco.ObjectFinder("a_default_prop_cm_categories-cntrl", "c_default_prop_cm_categories").setOptions(
{
field: "prop_cm_categories",
compactMode: true,
mandatory: false,
currentValue: "",
selectActionLabel: "Sélectionner",
minSearchTermLength: 1,
maxSearchResults: 1000
}).setMessages(
{""}
);
picker.setOptions(
{
itemType: "cm:category",
multipleSelectMode: true,
parentNodeRef: "alfresco://category/root",
itemFamily: "category",
maintainAddedRemovedItems: false,
params: "",
createNewItemUri: "",
createNewItemIcon: ""
});
})();
//]]>
</script>
</div>
</div>
And I have declared a JS dependency in the same file: dnd-upload.get.html.ftl
<#script type="text/javascript" src="${url.context}/res/components/object-finder/object-finder.js" group="objectfinder"/>
When I click on the button : "Sélectionner" , nothing happens and I have no console error neither.
Do you , Please, have any idea about how to make this Picker Working ?
Regards,
Sofia.