There's no problem about rendering that attribute in the html tag. You can do it the same way you'd do it with any other attribute (class, id ...).
For instance (I've changed the action a bit to adapt it to my SF installation):
{{ form_start(form, {'action': path('_demo_hello',{'name':5}),'attr': {'class': 'smart-form userform','id':'formid', 'onsubmit':'return validateForm();'} } ) }}
would render:
<form name="contact" method="post" action="/symfony/web/app_dev.php/demo/hello/5" class="smart-form userform" id="formid" onsubmit="return validateForm();">
If you have the js function validateForm
well set up, it should work. Anyway, if it didn't, that would be a problem related to your js and not to SF.
As pointed out in the comments, it'd be better practice to attach the submit event to the element using js instead of adding it in the HTML tag. You can do that using either jQuery or pure js (which is pretty straightforward too, no need to rely on jQuery always).