I have a MultiDatesPicker control where the user can select some dates.
A textarea object filled automatically with dates, while the user selects some of them. Everything is working fine.
What I liked to do now is, to check the length of that textarea so when the length is > 60 to change its width to 200px and when is <=60 the width will be 90.
I have done the following:
<script type="text/javascript">
$(document).ready(function () {
$.datepicker.setDefaults($.datepicker.regional['el']);
$('#cPublDates').multiDatesPicker({
altField: '#tbPublishDates'
});
$(function () {
$('#tbPublishDates').change(function () {
alert('changed');
if ($(this).val().length > 60) {
$(this).width(200);
} else {
$(this).width(90);
}
});
});
});
</script>
and the objects are
<div class="pulicationBox">
<span id="cPublDates"></span>
<asp:TextBox ID="tbPublishDates" runat="server" ClientIDMode="Static" TextMode="MultiLine" Rows="5" Width="90px" />
</div>
but didn’t work because the change() event is not fired. The #tbPublishDates is the id of the textarea.
Any ideas or code correction would be welcome since I am newbie in jQuery.
Thank you
Probably your problem is because it’s the multidaypicker that adds values to the textarea, hence jquery change() won’t trigger. I’d suggest you to use the multidatepicker event onSelect() to instead check the length of the textarea.
});
See the http://multidatespickr.sourceforge.net/ documentation.