how to use focus function javascript

 focu()  function  is use in javascript for focus of input box when you enter any wrong values in inputbox
for example email , mobile number .. etc

example :function emailvalidation(){ var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; email = document.getElementById(’email’).value ; if(emailPattern.test(email)==false){ alert(‘please Enter Valid Email Id’); document.getElementById(’email’).focus(); return false ; } }
Email Id :
when you enter wrong email them your cursor blink on input box

 code : in javascript  document.getElementById(’email’).focus();

in jquery    $(‘#email’).focus() ;   where email s id of input box


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s