Display a Message when the File Attachment field is empty while submitting a form.

Vinay Cherku1
Tera Contributor

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;
                }
        } 
    }

3 REPLIES 3

Community Alums
Not applicable

Hi @Vinay Cherku ,

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:

find_real_file.png

Mark my answer correct & Helpful, if Applicable.

Thanks,
Sandeep

 

Vinay Cherku1
Tera Contributor

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.

SumanthDosapati
Mega Sage
Mega Sage

Hi @Vinay Cherku 

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