Check if People Picker field is empty.

rss

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 Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 11 months 29 days
    #1 by Dmitry Kozlov Aug 6 ’14 at 02:37

    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

  • ching29
    Member
    Member for: 5 years 6 months 9 days
    #2 by ching29 Aug 7 ’14 at 03:14

    Thanks for this Dmitry.. It really helped...!

  • schuess
    schuess
    Member
    Member for: 5 years 7 months 27 days
    #3 by schuess Dec 14 ’15 at 10:51

    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 Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 11 months 29 days
    #4 by Dmitry Kozlov Dec 15 ’15 at 03:24

    [#3]: Please, use the code below:

    if (fd.field('InternalName').value().length == 0) {
    …
    }
    
Displaying 1 to 4 of 4 messages