Jump to content

Disable Submit Button if checkbox value is "Yes"


Recommended Posts

I have a checkbox field "AppLocked" that when checked I would like the submit/update button to be disabled (or hidden) and for their to be an alert that says "Your application is locked from edits. To submit any changes please contact your federation manager."

Is there a simple code I can use for this purpose?

Link to comment
Share on other sites

In some cases this would work, but in many of my datapages I already have rules and conditions applied that do not allow me to to then disable fields.

For the first time a user access the datapage, I have rules that set required fields, hide sections, etc. However, once they submit the page, a checkbox changes to "submitted" when that field is checked, if the user goes back to look at their information, I want to disable the ability for them to submit NEW changes to the datapage. I want to lock it from any further changes. Thus I do need JS because I cannot use the disable the fields  in the rules section since they are already being used for other conditions.

Link to comment
Share on other sites

You can have this code in Footer of your update page:

 

<script>
if (document.getElementById('EditRecordApproved').checked){
document.getElementById('Mod0EditRecord').style.display="none";
}
</script><script>
if (document.getElementById('EditRecordApproved').checked){
document.getElementById('Mod0EditRecord').style.display="none";
}
</script>

<script>
if (document.getElementById('EditRecordCHECKBOXFIELDNAME').checked){
document.getElementById('Mod0EditRecord').style.display="none";
}
</script>

 

Replace CHECKBOXFIELDNAME with the actual field name

Link to comment
Share on other sites

  • 4 weeks later...

Hi MayMusic,

I have had this script working on my pages for a while now. I recently changed some of my workflow so that the webpages now include a navigation menu that is a datapage in and of itself. This has made some of the script stop working. I've used this tutorial recommended by support to help me troubleshoot some issues.

How can I rewrite this simple script which had been working prior to deploying a second datapage:

<script>

if (document.getElementById('EditRecordAppLocked').checked){
document.getElementById('Mod0EditRecord').style.display="none";
}

</script>

 

Any thoughts about how to use this with an .onload function that can then call the correct datapage by adding  document.forms[1].onload to the script....

 

Link to comment
Share on other sites

Sorry just saw your message when you have more than one page deployed on a web page, all the IDs are going to be the same for buttons and the rest so when you refer to an ID it only picks the very first one. Same thing for the DataPage itself.

 

If you are referring to a DataPage you need to add Header/Footer and create an ID for the page

Header: <div id="myPage">

Footer: </div>

 

And then in your code for instance if you have document.getElementById('caspiofrom') you can use: document.getElementById('myPage')

Link to comment
Share on other sites

  • 6 years later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...