I try to disable only one Date and Time field using jQuery using Script Editor
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>
First I try to disable using id of element as:
$("#Fechados_fb10b3d7-d448-474d-af75-13c64038c3e5_\\$DateTimeFieldDate").attr("readonly", true);
I don´t have any errors on console but field not disabled
I also try:
<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>
but this line:
var itemID = $(" input[title='Fechados'] ").attr("id");
Always get
undefined
How can I achieve correctly it? Regards