Is the form also going to be submitted using AJAX?
You probably don't want onkeypress. That would call the function when a key is pressed. More likely what you want is to make sure that a) the user has put at least something in the field before pressing the submit button, or b) that what the user has input in the field has the correct formatting (like email or date, for example).
In the case of a), you probably don't want to check anything until the user tries to submit the form. In that case you would want to bind the click even of the submit button to a function which first checks to make sure any required fields are filled in, and if they are submits, but if not, inserts some little red error messages (or some such).
In the case of b), you probably want to bind a function to the leave fucus event (not sure what this event is actually called, but look it up). That way when the user has finished entering something into the field and is about to move on, it runs the function (which you have to write using regular expressions, most likely) and checks that the formatting is right - if it's not, the function will have to insert the little error messages wherever appropriate.
Cheers, and good luck.