Required Field based on user Selection

rss

Posted by coresoul - Feb 26 ’15 at 12:56

i have a checkbox filed called travelRequired (Yes/No) and a number field called TravelPercentage. Initially i want to hide TravelPercentage. If user selects travelRequired as Yes, i want to show TravelPercentage and make this field required. if user unselect the checkbox, it should clear the TravelPercentage field and hide that field.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 9 years 8 months 7 days
    #1 by Dmitry Kozlov Feb 27 ’15 at 09:48

    Hi,

    You can find examples of making fields mandatory or hiding fields based on other field values in the following post:

    http://formsdesigner.blogspot.com/2014/07/how-to-conditionally-hide-disable-make.html

  • coresoul
    Member
    Member for: 8 years 3 months 3 days
    #2 by coresoul Mar 4 ’15 at 11:33

    Here, checktype is a dropdown field. everything works except clearing the AFH_x0020_Replacement_x0020_Reas field when value in dropdown changed. Am i doing something wrong.

    function checktype(){

    if(fd.field('AFH_x0020_Type').value()=='Replacement'){

    $('.replacementreason').show();

    }

    else{

    fd.field('AFH_x0020_Replacement_x0020_Reas').value('');

    $('.replacementreason').hide();

    }

    }

    fd.field('AFH_x0020_Type').change(checktype);

     

    checktype();

  • coresoul
    Member
    Member for: 8 years 3 months 3 days
    #3 by coresoul Mar 4 ’15 at 11:38

    [#2]: sorry AFH type is a dropdown field

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 9 years 8 months 7 days
    #4 by Dmitry Kozlov Mar 5 ’15 at 04:16

    [#3]: This code works well for me:

    fd.field('AFH_x0020_Replacement_x0020_Reas').value('');

    Please, make sure that you use the correct internal name of the field and that the field type is Choice (DropDown).

  • coresoul
    Member
    Member for: 8 years 3 months 3 days
    #5 by coresoul Mar 6 ’15 at 10:32

    [#4]: Hi it didn't work for me. i forgot to mention that the field that i am trying to clear is a multiple line textbox, if that makes difference

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 9 years 8 months 7 days
    #6 by Dmitry Kozlov Mar 9 ’15 at 06:10

    [#5]: What type of the multiline text field do you use: Plain text, Rich text, or Enhanced rich text?

  • coresoul
    Member
    Member for: 8 years 3 months 3 days
    #7 by coresoul Mar 11 ’15 at 07:36

    [#6]:  i have all three types in the form (Plain text, Rich text, or Enhanced rich text)

  • coresoul
    Member
    Member for: 8 years 3 months 3 days
    #8 by coresoul Mar 13 ’15 at 09:21

    [#6]: i need your help please

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 9 years 8 months 7 days
    #9 by Dmitry Kozlov Mar 14 ’15 at 08:15

    [#8]: Hi,

    You can find samples of getting/setting fields of different types in our blog:

    http://formsdesigner.blogspot.com/2013/04/getting-and-setting-sharepoint-form.html

Displaying 1 to 9 of 9 messages