Required Field based on user Selection

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
coresoul
Posts: 23
Joined: Tue Feb 24, 2015

26 Feb 2015

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.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

27 Feb 2015

Hi,

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

http://spform.com/office-365/cond ... ynamically

coresoul
Posts: 23
Joined: Tue Feb 24, 2015

04 Mar 2015

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
Posts: 23
Joined: Tue Feb 24, 2015

04 Mar 2015

sorry AFH type is a dropdown field

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

05 Mar 2015

This code works well for me:

Code: Select all

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
Posts: 23
Joined: Tue Feb 24, 2015

06 Mar 2015

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

09 Mar 2015

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

coresoul
Posts: 23
Joined: Tue Feb 24, 2015

11 Mar 2015

i have all three types in the form (Plain text, Rich text, or Enhanced rich text)

coresoul
Posts: 23
Joined: Tue Feb 24, 2015

13 Mar 2015

i need your help please

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

14 Mar 2015

Hi,

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

http://spform.com/forms-designer- ... eld-values

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests