HTML5 version:
<input type="text" id="name" name="name" [COLOR="#FF0000"]required[/COLOR]>
The required attribute will do exactly as you want. However, it is absolutely not a substitute for server-side validation. In the case of text inputs all required really does is check for empty.