Hide the ‘Attach Files’ Option

So I got asked today for a way to block end users from attaching files to list items on a particular list. So I whipped out jQuery and quickly wrote a little selector to hide that page region. So you can see I just go off of the Attach File image and go up a few levels to get both img and the text label. Then I flag them as hidden.

If you’ve ever heard of me, you’ll know that I am a *huge* jQuery fan. However, this is, to me, an excellent example if a time not to use jQuery. A simple bit of CSS will take care of it and be more reliable.

Understanding when to pull out jQuery and when not to is one of the things I try to teach my students at USPJ Academy (http://uspja.com).

Unfortunately with how SharePoint 2007 has the attach item done theres really no good selector for CSS (pre-CSS3) to get just the attach item link and image. Using normal CSS2.x selectors you would end up hiding quite a few page regions.

But you’re absolutely right, if you have your page elements properly segmented and identified CSS is a MUCH better route to go.

I had a requirement to allow this on some forms and not on others within the same list. The easiest way I’ve found to do this at the form level is to create a custom form in SP Designer and check the box to disable the standard toolbar. This will make it so the attachment link isn’t visible for that form. No coding required.