jQuery: Validity code snippet