1

I am using following "code" to disable people picker in custom edit form:

$("div[id$='_UserField_upLevelDiv']").attr("contentEditable",false);//Disabling People picker
$("span[id$='_UserField']").find("img").hide(); //hiding search field and check which are adjacent to people picker

Control is disabled but when there is something (or rather someone) in the field already, I can select that person and delete it by pressing delete on the keyboard. Is there a way of restricting that behavior?

Just found out that it is working fine in IE10 but not in Chrome.

1 Answer 1

0

This is kind of a half answer, because I am not sure why this works. If you only set disabled or if you only set contenteditable, the field can still be edited. However, if you set both, it works as desired.

 $("div[id$='_UserField_upLevelDiv']").attr({
    "contenteditable": false, 
    "disabled": "disabled"
});

Also, if you are using jQuery 1.6+, you want to use prop. I tested with an old jQuery version, so I left my answer using attr.

2
  • Nope, it didn't work. the same behavior. When checked in IE, both are working fine.In Chrome I can delete people picker value.
    – Ulee
    Mar 31, 2016 at 5:27
  • I was able to reproduce in chrome. This amended answer worked for me.
    – Matt
    Mar 31, 2016 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.