Reputation: 13854
i am trying to combine bootstrap datepicker along with some text.Say for example
hello 12/12/2013
In the jsfiddle Suppose if i write hello and then choose a date then the word hello is replaced by the date. this is the jsfiddle showing bootstrap datepicker,Please tell me how to append some text along with datepicker.Following is the jquery code to get the datepicker.i am referring this site for bootstrap datepicker
$('#datetimepicker').datetimepicker({
format: 'dd/MM/yyyy hh:mm:ss',
language: 'pt-BR'
});
Upvotes: 1
Views: 2887
Reputation: 1531
You can do something like this..
var val=" ";
$(function() {
$("#datetimepicker").datetimepicker({
format: "yyyy-MM-dd",
linkField: "#txt",
linkFormat: "yyyy-mm-dd",
autoclose: true,
});
jQuery('#datetimepicker').datetimepicker().on('changeDate', function(ev){
var chk=$(".darea1").val();
chk=chk.replace(val, " ");;
$(".darea1").val(chk);
$(".darea1").val($( ".darea1" ).val()+$( "#txt" ).val());
val=$( "#txt" ).val();
});
});
check this fiddle
Upvotes: 2
Reputation: 2780
Simply, if you want the same text for any date chosen:
$('#datetimepicker').datetimepicker({
format: 'hello dd/MM/yyyy hh:mm:ss',
language: 'pt-BR'
});
And, if like in your example, you dont want the time:
$('#datetimepicker').datetimepicker({
format: 'hello dd/MM/yyyy',
language: 'pt-BR'
});
See this jsfiddle.
Upvotes: 2