web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

Checkbox Value Not Saved via Javscript

(1) ShareShare
ReportReport
Posted on by 60

The following JavaScript is triggered on a Microsoft Dynamics Portal (Basic Form), where I validate that user must check at least one of the checkbox.

  • Both checkboxes are not checked on form load
  • On form submit, there is a validation to check at least one is checked
  • Once either checkbox is checked, they cannot uncheck both checkboxes

Problem: The checkbox that is checked, is not saved when the form is submitted. Am I missing an additional save function?

$(document).ready(function () {

if (typeof (Page_Validators) == 'undefined') return;

var stepZeroValidator = document.createElement('span');
stepZeroValidator.style.display = "none";
stepZeroValidator.id = "stepZeroValidator";
stepZeroValidator.errormessage = "Please provide your consent before submitting the application.";
stepZeroValidator.initialvalue = "";
stepZeroValidator.evaluationfunction = function () 
{
if (document.getElementById('ccc_personaldataprotectionactyes').checked == false && document.getElementById('ccc_personaldataprotectionactno').checked == false){
return false;  //Apply Validation
}
else{return true;}
}
// Add the new validator to the page validators array:
Page_Validators.push(stepZeroValidator);

$("#ccc_personaldataprotectionactyes").bind('change', function () {
    if (document.getElementById('ccc_personaldataprotectionactyes').checked = true) {
        document.getElementById('ccc_personaldataprotectionactno').checked = false;
    }
    else if (document.getElementById('ccc_personaldataprotectionactyes').checked = false) {
        document.getElementById('ccc_personaldataprotectionactno').checked = true;
    }
});

$("#ccc_personaldataprotectionactno").bind('change', function () {
    if (document.getElementById('ccc_personaldataprotectionactno').checked = true) {
        document.getElementById('ccc_personaldataprotectionactyes').checked = false;
    }
    else if (document.getElementById('ccc_personaldataprotectionactno').checked = false) {
        document.getElementById('ccc_personaldataprotectionactyes').checked = true;
    }
});
});

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi ruihaolrh,

    Could you provide the screenshot of basic form? And did you add an onload event handler?

  • ruihaolrh Profile Picture
    60 on at

    Hi Steve,

    Appreciate your assistance. My JavaScript is triggered in the 'Custom JavaScript' section in my Web Form Step, as follow:

    pastedimage1644217056027v1.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 55 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 25 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans