- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2017 02:42 AM
How to restrict a form to be submitted in JavaScript?
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2017 02:49 AM
You can restrict the form submission, through onSubmit Client Scripts/ Business Rules.
onSubmit client scripts:
- function onSubmit() {
- if(g_form.getValue('ad_domain') == 'YES' || g_form.getValue('ad_domain') == 'YESb' && g_form.getValue('question_choice') == 'incorrect info' ) //assuming values are YES and YESb
- {
- if(g_form.getValue('user_confirm') == 'false' ){
- var result = confirm('Are you sure you wish to submit?');//or whatever that checkbox is for
- if (result) {
- g_form.setValue('checkbox', true);
- else
- return false; //Here return false will stop the submission of the form.
- }
- }
- }
Business Rules:
- (function executeRule(current, previous /*null when async*/) {
- ....
- if (<condition to prevent delete>) {
- gs.addErrorMessage(gs.getMessage("You cannot delete a task where users have logged time against the task."));
- current.setAbortAction(true); //setAbortAction will prevent the data to be inserted/updated
- }
- })(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2017 02:45 AM
Use can make use of onsubmit client script on the form to restrict for subitting
EG:
function onSubmit() {
alert(g_form.getValue('ad_domain')); //To make sure value is YES. This is just for tesiting purpose.
if(g_form.getValue('ad_domain') == 'YES'){
if(g_form.getValue(user_confirm') == 'false' ){
alert('Please be sure to check the box before submitting a ticket.');
return false;
}
}
}
Please like or mark correct based on the impact of the response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2017 02:49 AM
You can restrict the form submission, through onSubmit Client Scripts/ Business Rules.
onSubmit client scripts:
- function onSubmit() {
- if(g_form.getValue('ad_domain') == 'YES' || g_form.getValue('ad_domain') == 'YESb' && g_form.getValue('question_choice') == 'incorrect info' ) //assuming values are YES and YESb
- {
- if(g_form.getValue('user_confirm') == 'false' ){
- var result = confirm('Are you sure you wish to submit?');//or whatever that checkbox is for
- if (result) {
- g_form.setValue('checkbox', true);
- else
- return false; //Here return false will stop the submission of the form.
- }
- }
- }
Business Rules:
- (function executeRule(current, previous /*null when async*/) {
- ....
- if (<condition to prevent delete>) {
- gs.addErrorMessage(gs.getMessage("You cannot delete a task where users have logged time against the task."));
- current.setAbortAction(true); //setAbortAction will prevent the data to be inserted/updated
- }
- })(current, previous);