I have this code:
HTML
Use the is function to test for the :invalid pseudoclass:
:invalid
if ($(this).is(":invalid")) { showMessage("Invalid value"); }
Example: http://jsbin.com/ikuwur/2/edit