Client Script: Pop up confirmation on Field Change
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 05:11 PM
I currently have a very basic client script that confirms a field change (Script Below). Is there a way if they select cancel on the prompt, it reverts the field value to what it was before?
function onSubmit() {
var legal = g_form.getValue('legal_review');
if (legal =='No'){
return;
}
var answer = confirm("Are you sure you want to set a Legal Review?");
if (legal =='Yes'){
// User clicked Cancel, prevent the form from being saved
return false;
}
}
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 05:33 PM
Hi @Scott29,
You can use hidden variable and copy the previous value and use that same in case of "Cancel".
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 05:59 PM
the following script may get you the behavior you want.
function onSubmit() {
//Type appropriate comment here, and begin script below
var legal = g_form.getValue('u_legal_review');
alert('u_legal_review = ' + legal);
if (legal =='No'){
return;
}
return confirm(getMessage('Are you sure you want to set a Legal Review?'));
// var answer = confirm("Are you sure you want to set a Legal Review?");
// if (legal =='Yes') {
// User clicked Cancel, prevent the form from being saved
// return false;
// }
}