why doesn't focus() work in the following line of jquery?

Posted by jela on Stack Overflow See other posts from Stack Overflow or by jela
Published on 2012-07-08T03:12:59Z Indexed on 2012/07/08 3:15 UTC
Read the original article Hit count: 99

Filed under:
|

The following code is intended to check if 4 numbers are entered in the blurred field. If not, the field value is deleted, and the field is focused. The deletion works fine, but the the call to focus() does not work.

$('input.dateValue').live('blur',function(event){
  if (!(/(\d){4}$/.test($(this).attr('value')))) $(this).attr('value','').focus();
});

Why does the call to focus() not focus the field?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery