RollerCosta RollerCosta - 5 months ago 28
jQuery Question

Jquery DatePicker to multiple elements.?

How to apply Jquery DatePicker to multiple elements. at once??

Suppose i have 3 TextBoxes




<td class="textBox">@Html.LabelFor(model => model.textbox1)
<td class="textBox">@Html.LabelFor(model => model.textbox2)
<td class="textBox">@Html.LabelFor(model => model.textbox3)



Now here i want to apply datepicker to all three textBoxex at once.


I also want to know is it possible to set mm-yy as datepicker format???


Updated

How to set regional datepicker dateFormat and dateRange at one step??

Answer


Changed @Html.LabelFor to

@Html.TextBoxFor(model=>model.textbox1,new{@class=textBox1}) @Html.TextBoxFor(model=>model.textbox1,new{@class=textBox1}) @Html.TextBoxFor(model=>model.textbox1,new{@class=textBox1})

Then used below script

<script type="text/javascript">

$(function () {
    alert(abc);
    $(".textBox").datepicker({
        changeMonth: true,
        changeYear: true,
        dateFormat: 'mm-yy',
        yearRange: '1900:2012'
    });
    $.datepicker.setDefaults($.datepicker.regional[""]);
    $(".textBox").datepicker($.datepicker.regional["en"]);
    $(".textBox").datepicker("option", $.datepicker.regional[anyculture]);
});