Have a check box enable an alert/a read only field and hide a field.

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

27 Apr 2017

On my edit form I have a due date field, an extend due date field and a reasons field, I would like that when the form loads the due date is read only and that when the extend due date tick box is ticked an alert appears, the reasons why field appears and the due date is no longer read only.... here is what I have so far, the script below shows the alert when the check box is ticked, the hidden field is shown but when the form loads the due date is not read only, i have 2 check the box, uncheck and then check again for it to work.I know there is a little missing from the below script, plus also is there a better more cleaner way to write it??


//show or hide the due date extension reasons
function setTMSreasons() {
if fd.field('Extended').value() == '1') {
$('.TMSreasons').show();
} else {
$('.TMSreasons').hide();
}
}
fd.field('Extended').change(setTMSreasons);
setTMSreasons();

//Alert for extended due date
function setExtendedreasons() {
if (fd.field('Extended').value() == '1') {
alert ('You have extended...........');
}
}
fd.field('Extended').change(setExtendedreasons);

//read only for due date
function setDue_x0020_Date() {
if (fd.field('Extended').value() =='1') {
fd.field('Due_x0020_Date').readonly(false);
} else {
fd.field('Due_x0020_Date').readonly(true);
setExtended();

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

28 Apr 2017

I cannot find definition of the setExtended function that you call at the end.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests