- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2024 06:06 PM
Only one error message is displayed at onSubmit.
When I resolve one error, another error appears.
If there is an error in two items, I want to display the error messages for both items at the same time at onSubmit.
Please let me know if you know how.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 07:17 AM
@user_ms Here is the updated script, it will hold the form submission until the error is corrected.
function onSubmit() {
g_form.clearMessages();
var fieldArray = ['test1', 'test2'];
var regex = /^[0-9]+$/;
var errorCount= 0;
for (var i = 0; i < fieldArray.length; i++) {
if (!regex.test(g_form.getValue(fieldArray[i]))) {
g_form.showFieldMsg(fieldArray[i], 'error!', 'error');
errorCount++;
}
}
if(errorCount==0){
return true;
}
else{
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2024 08:24 PM
@user_ms Here is the script you should use to show error messages for both the fields.
function onSubmit() {
g_form.clearMessages();
var fieldArray = ['test1', 'test2'];
var regex = /^[0-9]+$/;
for (var i = 0; i < fieldArray.length; i++) {
if (!regex.test(g_form.getValue(fieldArray[i]))){
g_form.showErrorBox(fieldArray[i], 'error');
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 06:46 AM
@user_ms Do you have any further questions on this topic. If not then please accept the answer as correct solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 06:51 AM
Thank you for your answer.
I tried the method you taught me.
I added "return false" to the source, but after fixing the error I can't submit.
I would like to be unable to submit unless I correct the error.
The error message has been changed to below.
g_form.showFieldMsg('test1', 'error!', 'error');
I would like to add the following error checking.(as test3,test4)
var regex2 = /^[\uFF61-\uFF9F\d_+*]+$/;
Do you know how to solve it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2024 07:17 AM
@user_ms Here is the updated script, it will hold the form submission until the error is corrected.
function onSubmit() {
g_form.clearMessages();
var fieldArray = ['test1', 'test2'];
var regex = /^[0-9]+$/;
var errorCount= 0;
for (var i = 0; i < fieldArray.length; i++) {
if (!regex.test(g_form.getValue(fieldArray[i]))) {
g_form.showFieldMsg(fieldArray[i], 'error!', 'error');
errorCount++;
}
}
if(errorCount==0){
return true;
}
else{
return false;
}
}