Display a Message when the File Attachment field is empty while submitting a form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 07:38 AM
Hi Everyone,
I am working on a Client script to display a message(Are you sure do you want to submit the form without an attachment?) when a File Attachment field is empty. but it is not working for the Client script I have written.
Please take a look at the following code and correct me where I am going Wrong
function onSubmit()
{
var attach = g_form.getValue('u_test');
if (attach == ' ')
{
var uInput = confirm("Are you sure do you want to submit the form without an attachment?");
if (uInput == true)
{
return true;
}
else
{
return false;
}
}
}
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 07:49 AM
Hi
Why have you created a additional attachment field where you can use the OOTB attachment.
for that you don't need any script, simply do below:
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 08:00 AM
Thank you for your response Sandeep.
But the client want it to be an "File Attachment " field on a Scoped Application. And they don't want it to be mandatory field. But a Message should pop up whenever an attachment is not attached to that field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 08:05 AM
Hi
You can try this script
function onSubmit() {
if(!g_form.getValue('u_test')){
{
var response = confirm("do you want to proceed without an attachment?");
if(!response)
{
return false;
}
}
}
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth