Passing javascript to HTML

I am using ruby ​​gem bootstrap-datepicker-rails in a Rails-4 application to draw a form to accept from_date

and till_date

as input as next. The beauty of this code does not require javascript like the jewel coded in this code.

<div class=" input-daterange" id="datepicker" data-provide='datepicker'>
  <label>From Date</label>
  <input type="text" class="form-control" name="from_date" id="from_date">

  <label>Till Date</label>
  <input type="text" class="form-control" name="till_date" id="till_date">
</div>

      

By default it accepts the format as "mm / dd / yyyy", I want to change it to "yyyy-dd-mm", is it possible to do this by passing this only in html options and not using javascript for this. I tried following some other permutations as well, but of course they didn't work.

<div class=" input-daterange" id="datepicker" data-provide='datepicker' options='format:"yyyy-mm-dd"'>

<div class="row input-daterange" id="datepicker" data-provide='datepicker' format="yyyy-mm-dd" >

      

Please let me know if this can be done and how.

+3


source to share


2 answers


The docs suggest you do it like this:

<input class="datepicker" data-date-format="mm/dd/yyyy">

      



https://bootstrap-datepicker.readthedocs.org/en/latest/#configuration

Note that the attribute extends to the input element and is called date-date format

+3


source


I think you are missing the correct html attribute name, try:

data-date-format="yyyy/mm/dd"



Source: documentation

+1


source







All Articles