Auto move (Auto Tab)cursor onto next form field using Javascript | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

Auto move (Auto Tab)cursor onto next form field using Javascript

Thursday

Auto Tab Form Fields using JavaScript:
                   This a simple sample code for auto tab form fields using javascript.  It works in conjunction with the "maxlength" attribute of HTML, triggered whenever the user's input reaches the maxlength's value.
Code:

<script type="text/javascript">
/*
Auto tabbing script http://codingcluster.blogspot.in/
*/
function autoTab(current,next){
if (current.getAttribute&&current.value.length==current.getAttribute("maxlength"))
next.focus()
}

</script>

<b>Enter your input:</b>
<form name="fromAutoTab">
<input type="text" name="first" size="4" onkeyup="autoTab(this, document.fromAutoTab.second)"
    maxlength="3" />
<input type="text" name="second" size="4" onkeyup="autoTab(this, document.fromAutoTab.third)"
    maxlength="3" />
<input type="text" name="third" size="5" maxlength="4" />
</form>
  Try this demo:
  Enter your input:

5 comments:

Anonymous said...

Can you make it work for iPad Safari?

Anonymous said...

Thank you so much it working fine

Unknown said...

when i use it in cshtml, it is throwing error.

Unknown said...

when i use it in cshtml, it is not working. how to use this script in @html.editfor in mvc3.

Anonymous said...

it's not working :(

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets