Attach from customer portal

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.

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;

can you help me?