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;