Make fields mandatory using a radio button

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Hir
Posts: 4
Joined: Wed Jul 06, 2016

06 Jun 2016

Hello,

I have a radio button with choices yes and no, i would like to make field A,B and C ( these are all single line fields) mandatory if radio button choice is selected as 'Yes'. I have tried to use couple of different validations but it always checks to be true even when radio button is selected as 'No'. Can you please help with this? Thanks in advance!

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

07 Jun 2016

Hi,

If you use the Choice field, fd.field().value() will return 0-based index of the selected option:

Code: Select all

fd.onsubmit(function() {
    if (fd.field('FieldName').value() == 0) {
        //check mandatory fields here
        //return false;
    }
    
    return true;
});
Please, read the post:
http://spform.com/forms-designer- ... eld-values

Hir
Posts: 4
Joined: Wed Jul 06, 2016

07 Jul 2016

Thanks for your replay. I got it working with following.

fd.onsubmit(function(){

if ((fd.field('Choice Field').value() == 1) && (fd.field('A').value()=="")|| (fd.field('B').value=="")||(fd.field('C').value=="")){

alert('Fields A, B and C cannot be left blank if choice is No.');

return false;

}

return true;

})

lijupnandanan
Posts: 16
Joined: Mon Apr 11, 2016

21 Sep 2016

Hi

I get radiobutton value from this

fd.field('FieldName').value()


but how can I get radio button text?

YuriyMedvedev
Moderator
Posts: 33
Joined: Wed Sep 21, 2016

22 Sep 2016

Hello!

Label of choosen radio you can get by this script:

Code: Select all

fd.field('Choice').control()._el().find( "input:checked" ).next().text()


where Choice is the internal name of column with radio-buttons.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests