Is there something I can do like this (perhap via a plugin)
if ( ! $(\'form#contact input]\').hasFocus()) { $(\'form#contact input:first]\').focus(); }
There is no native solution but yes there is a more elegant way you can do it:
jQuery.extend(jQuery.expr[':'], { focus: "a == document.activeElement" });
You're defining a new selector. See Plugins/Authoring. Then you can do:
if ($("...").is(":focus")) { ... }
or:
$("input:focus").doStuff();