So, previously in version 5.2 I could easily prompt a user with a javascript confirm dialog box that checked whether they had selected a checkbox in my edit form before saving that form. The idea was to simply ask the user whether they really wanted to save the form given that they had not checked-off a specific checkbox on the page. Basically a simple "are you sure" type of reminder before saving.
The way I did this in 5.2 was as follows:
I added simply this bit of JS directly in HTML via Visual Editor (in the HEAD tag of my page):
<script language=Javascript>
function decision(){
if (document.forms.editform1.value_myfield_1.checked == 0)
{
if (confirm('You have not checked off the "myfield" box. Are you sure you want to save?')) document.forms.editform1.submit(); else return false;
} else document.forms.editform1.submit();};
</SCRIPT>
However, this didn't method stopped working in version 5.3 because of the new "popup" functionality of add/edit/view forms. This new feature breaks the old model of using "editform1" and "value_myfield_1"... so we can no longer reference those fields directly ahead of time. The new popup forms are generated on the fly, thus you have to use the PHPR API to refer to objects such as var ctrl_Home_Phone= Runner.getControl(pageid, 'Home_Phone'). Unfortunately, the API left out a way for us to refer to the "SAVE" button on the form using the JS onLoad event... so, even though I was able to attach onclick events to the save button (via jquery and/or directly adding it as an attribute in HTML) it nonetheless would always fire the default pre-built save event with the form as well (in other words, I would not stop the event from saving, even when selecting cancel action in the JS confirm dialog box).
Long story short... with a little help from support here is some code you can use to create a confirm dialog when saving a form in 5.3 (place in JS onLoad event of edit and/or add form):
var ctrl_My_Field= Runner.getControl(pageid, 'My_Field');
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
if(ctrl_My_Field.getValue() == 0) {
if (confirm('You have not checked off the "myfield" box. Are you sure you want to save?')) {return true;} else {return false};
} else {
return true;
}
}
);
That's all. Cheers,