Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
75
rated 0 times [  77] [ 2]  / answers: 1 / hits: 17861  / 8 Years ago, tue, august 23, 2016, 12:00:00

The below method sends date to text box in this format Wed Sep 14 2016 00:00:00 GMT+0400.
So i tried to use substring method to get date in this format Sep 14 2016



i have tried to it in below code but it didn't work



it return this error Uncaught TypeError: date.substring is not a function



<script>
$(document).ready(function () {
var dateval = $('#<%= txtdate.ClientID %>').val();
if (dateval != '') {

var options = {
selectedDate: dateval,
size: 'medium',
width: 960
}
} else {
var options = {
size: 'medium',
width: 960
}
}
$('#paginator').datepaginator(options);
$('#paginator').on('selectedDateChanged', function (event, date) {
$('#<%= txtdate.ClientID %>').val(date.substring(4, 12));
});
});
</script>

More From » jquery

 Answers
11

You must convert date to string and then use sub string



like this



$('#<%= txtdate.ClientID %>').val(date.toString().substring(4, 12));

[#60955] Friday, August 19, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zayne

Total Points: 366
Total Questions: 98
Total Answers: 98

Location: India
Member since Wed, Aug 4, 2021
3 Years ago
;