refactored jquery validate code