OP,
You've gotten a lot of responses and suggestions on what to do. However, I’m wondering… what do you want? An apology from United, change in COC or other policies, additional training of the flight crew regarding rules and regulations, reprimand/punishment/disciplinary action against the Captain, compensation, etc? What would make you feel better about the situation? Until you provide an answer to that question, it’s hard to give you worthwhile advice.
Regardless of what every individual’s opinion on “dress code” may be, the disclosed (and presumed) facts or this “Situation” point to the Captain being in the wrong. Even though it was not a violent battery, the Captain touched you unwillingly. It’s not too far to consider that assault as well (based on my basic understanding of the law). As a result, you should have a strong basis to get whatever you want out of this within reason. If you sincerely felt that you were damaged or your flight experience was altered in a material way as a result from this event, I think you’ve got an argument.
Let us know what you want to come of this "Situation" and any results/correspondence with UA.