- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 10:33 AM
Hi!
I'm having trouble with setting a field to mandatory after submitting the form. I made an onSubmit client script with the usual script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 10:47 AM
Since you are using g_form and only need to set read-only on submitted forms, you may want to consider the isNewRecord module and running onLoad.
function onLoad(){
if(!g_form.isNewRecord()){
g_form.setMandatory('field',true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 10:38 AM
Hi @Momiji ,
The onSubmit() client script runs right before the form is submitted. If you return false, the form won't submit.
To make the field mandatory, please use an onload client script or on change with necessary conditions required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 10:47 AM
Since you are using g_form and only need to set read-only on submitted forms, you may want to consider the isNewRecord module and running onLoad.
function onLoad(){
if(!g_form.isNewRecord()){
g_form.setMandatory('field',true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 11:15 AM
thanks @Ryan122! I used your script and it works!