Yup, onclick would indeed be considered obtrusive.
You might want to use a third-party validation library in javascript.
It could work something like this:
<form ... class="validated">
  <input type="text" name="name" data-validation="presence=true,format=/[a-zA-Z0-9\s]+/" />
  <input type="submit" value="Send" />
</form>
<script language="javascript">
  $('form.validated').live('submit', function() {
    var data = $(this).serializeArray();
    var errors = [];
    $(this).find('input').each(function() {
      var input = $(this);
      $.each($(this).attr('data-validation').split(','), function(validation) {
        var type, param = validation.split("=");
        if(type == "presence") {
          if(input.val() == "") errors += input.attr('name') + " is empty";
        } else if(type == "format") {
          ...
        }
    });
    return (errors.length == 0);
  });
</script>
(Just some rough code out of my head. Lots of caveats there.)
But instead of writing all that, perhaps you just want to use: http://github.com/jzaefferer/jquery-validation