I want to disable Date and Time picker but I can´t get input textbox, I always get undefined
Code
<script>
// Search for the input textbox of DatePicker by its title and get its Item ID
var itemID = $(" input[title='Fechados'] ").attr("id");
// Trim the Item ID and keep the first part which is common for each element of this DatePicker
var itemCode = itemID.substring(0, itemID.indexOf('$'));
// Set text input to readOnly
$( "[id^=" + itemCode + "] td.ms-dtinput > input[id$='Date']" ).attr('readonly', 'readonly');
// Disable the onclick action on the button
$( "[id^=" + itemCode + "] td.ms-dtinput > a" ).attr('onclick','').unbind('click');
// Disable the 2 time select elements
$( "[id^=" + itemCode + "] td.ms-dttimeinput > select[id$='DateHours']" ).attr('disabled', 'disabled');
$( "[id^=" + itemCode + "] td.ms-dttimeinput > select[id$='DateMinutes']" ).attr('disabled', 'disabled');
</script>
This line always throw me undefined:
var itemID = $(" input[title='Fechados'] ").attr("id");
I don´t know why if Title of my column is correctly. Regards
Message received in console:
Uncaught TypeError: Cannot read property 'substring' of undefined
HTML:
<td class="ms-dtinput">
<label for="Fechados_fb10b3d7-d448-474d-af75-13c64038c3e5_$DateTimeFieldDate" style="display:none">Fechados Date</label>
<input type="text" value="31/08/2017" maxlength="45" id="Fechados_fb10b3d7-d448-474d-af75-13c64038c3e5_$DateTimeFieldDate" title="Fechados" class="ms-input" autopostback="0">
</td>