I use this plugin for jquery validation: http://jqueryvalidation.org
This is not problem when I need: required, required number etc., I just put in element class like this:
<input type="text" id="" value="" name="name"size="40" class="required"
In my example I need required number but only if is input not blank, when i use
<input type="text" id="" value="" name="name"size="40" class="required number"
user can't leave this input.