Check if People Picker field is empty.
Posted by ching29 - Aug 5 ’14 at 01:58
Hello,
I would like to ask how to validate people picker field if it is empty using javascript? I already have a validation for text but cannot seem to replicate it and use in peoplepicker field. Please help. Thanks.
I already read this http://formsdesigner.blogspot.com/2013/04/getting-and-setting-sharepoint-form.html but still cant make it work.
Best Regards,
Erica
-
Dmitry KozlovAdminMember for: 8 years 9 months 7 days
Hello Erica,
Here is the sample:
if (fd.field('AssignedTo').value().dictionaryEntries.length == 0) { // AssignedTo is empty }
You can find more samples on how to validate fields, make them mandatory or hide them conditionally in the following post:
http://formsdesigner.blogspot.com/2014/07/how-to-conditionally-hide-disable-make.html
-
ching29MemberMember for: 8 years 3 months 17 days
Thanks for this Dmitry.. It really helped...!
-
schuessMemberMember for: 8 years 5 months 5 days
This worked for me when I had the field Render = Server, However, now I am using Render = Client, and the .value().dictionaryEntries.length == 0 validation check is not working.
-
Dmitry KozlovAdminMember for: 8 years 9 months 7 days
[#3]: Please, use the code below:
if (fd.field('InternalName').value().length == 0) { … }