Question

I have 3 date fields into my list, but I want to disable one of them.

Column name = Fecha

I try to achieve it adding Script Editor like this:

enter image description here

Code:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>

<script>
var itemID = $(" input[title='Fecha'] ").attr("id");



var itemCode = itemID.substring(0, itemID.indexOf('$'));



$( "[id^=" + itemCode + "] td.ms-dtinput > input[id$='Date']" ).attr('readonly', 'readonly');



$( "[id^=" + itemCode + "] td.ms-dtinput > a" ).attr('onclick','').unbind('click');



$( "[id^=" + itemCode + "] td.ms-dttimeinput > select[id$='DateHours']" ).attr('disabled', 'disabled');

$( "[id^=" + itemCode + "] td.ms-dttimeinput > select[id$='DateMinutes']" ).attr('disabled', 'disabled');
</script>

But it just don´t works, I try to debug it into new item view but I cant see code of script I insert into Script Editor, what is wrong there? Regards

Was it helpful?

Solution

Your js code does not run, because you have added Scrip Editor Web Part to the list view. If you want to disable field in New Item form, you have to modify Default New Form and add appropriate code there: Editing Default New Form

You can do same thing with Default Edit Form

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top