Conditionally disable button

rss

Posted by Katy - Dec 16 ’16 at 10:56

 

I am trying to make a button disable when the status field is Completed, I found this tread :

http://forum.spform.com/forms-designer-for-sharepoint-20/button-disable-and-enable-27284/

and here is my code:

 

function ButtonDisable() {
if (fd.field('Satus').value() == 'Completed') {

$('.approve-button').prop('disabled', true);
} else {

$('.approve-button').prop('disabled', false);
}
}
fd.field('Satus').change(ButtonDisable);
ButtonDisable();

but it is not working L

 

 

 

  • YuriyMedvedev
    Moderator
    Member for: 3 years 17 days
    #1 by YuriyMedvedev Dec 19 ’16 at 08:24

    Hi, use this code

    function ButtonDisable() {

    $('.approve-button').prop('disabled',

    (fd.field('Title').value() != 'Completed'));

    }

    fd.field('Title').change(ButtonDisable);

    ButtonDisable();

  • Katy
    Member
    Member for: 5 years 2 months 28 days
    #2 by Katy Dec 19 ’16 at 09:25

    [#1]: Thanks Yuriy! It works. Just changed != to ==, as it was disabling the buttons when the status is not completed :-)

Displaying 1 to 2 of 2 messages