Sunday, August 4, 2013

Make the auto-poplated fields read-only in the NewForm?

Since you're using JS to populate the fields you can't use anything server side to lock the fields. If you did it there then obviously it would prevent you modifying them using JS.


It should be a simple case of setting the 'disabled' property



<script type="text/javascript" language="javascript">
$(document).ready(function() {
var userName = $().SPServices.SPGetCurrentUser({
fieldName: "Title"
});
$("input[Title='Initiator']").val(userName);
$("input[Title='Initiator']").disabled = true;
});</script>


No comments:

Post a Comment