I use the jQuery replace function to ensure that users can only enter digits and hyphens into the phone number field (its a private web app, and JS has to be enabled to login).
I want to add a css class (highlight red) to the input for x seconds after the replace function is fired so the user sees visually that the input is rejecting there input.
How do I add a css class to the input for x seconds after the replace function is activated? (only when a input is actually replaced)
$("#v_phone").bind('keyup blur',function(){
$(this).val( $(this).val().replace(/[^\d-]/g,'') ); }
);
Use
setTimeout():DEMO.