Attach from web form

I need a client script for a web form that limits the types of files that can be attached.

I need to be able to attach files, pdf, docx and xlsx.

can you help me?

my code, but not working.

frappe.web_form.validate = () => {
if (!(frappe.utils.validate_type(frappe.web_form.get_value(“attachment”), “.pdf”))) {
frappe.msgprint(‘Invalid format’);
return false;
}
}

hi create a js file with name of your web form inside public folder
and use this code below just change the field name and the format you want and then call it from the hooks file
frappe.web_form.on_load = function () {

let field = frappe.web_form.fields_dict\["resume_attachment"\];

if (field) {

field.on_attach_click = function () {

field.set_upload_options();

field.upload_options.restrictions.allowed_file_types = [

“application/pdf”,

“.pdf”

        \];

field.file_uploader = new frappe.ui.FileUploader(field.upload_options);

    };

}

};

below is the hooks file calling code

web_include_js = “/assets/techner/js/job_applicant_webform.js”

if still any confusion let me know i will help you