- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2023 03:13 AM
I have a scenario where if the data in Task time fields is greater than zero, and the user tries to submit the form, he should get an error message to fill in the associated Task details.
For example, when user fills Task 3 time and Task 4 time values greater than zero, and tries to submit the form, he should get an error message that it's associated Task 3 details and Task 4 details should be filled.
I am trying to achieve it with a single functionality and avoid writing multiple onSubmit client scripts. Please help me with a script logic or an approach to implement it.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2023 03:37 AM
Hi @Novin Ramteke ,
You can use below script to achieve the same:
function onSubmit() {
var task1 = parseInt(g_form.getValue('task_1'));
var task2 = parseInt(g_form.getValue('task_2'));
var task3 = parseInt(g_form.getValue('task_3'));
var task4 = parseInt(g_form.getValue('task_4'));
var task5 = parseInt(g_form.getValue('task_5'));
var fields = [];
if(task1>0){
if(g_form.getValue("task_details_1") == ''){
fields.push("task_details_1");
}
- if(task2>0){
if(g_form.getValue("task_details_2") == ''){
fields.push("task_details_2");
}
if(task3>0){
if(g_form.getValue("task_details_3") == ''){
fields.push("task_details_3");
}
if(task4>0){
if(g_form.getValue("task_details_4") == ''){
fields.push("task_details_4");
}
if(task5>0){
if(g_form.getValue("task_details_5") == ''){
fields.push("task_details_5");
}
if(fields.length != 0){
g_form.addErrorMessage("Fill task details for these fields, since time is greater than 0 "+ fields);
return false;
}
}
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2023 04:28 AM
Awesome, glad to help!
Apologies, I was not using script editor so might have missed a few.
Aman Kumar