Welcome visitor
* Login
* Register
It is currently May 20th, 2019, 6:42 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  go to next field automatically
PostPosted: May 30th, 2009, 4:42 am 
User avatar

Posts: 52
hi, i have a form with fields to enter a phone number in the format (aaa)-ppp-pppp. how can i make the focus skip to the next field once the current is filled (with 3, 3 and 4 numbers)?


Top
 Profile  
 
  Re: go to next field automatically
PostPosted: May 30th, 2009, 6:02 am 
User avatar

Posts: 136
    <script type="text/javascript">
    function validate(t){
    if(event.srcElement.value.length==t)
        {var i=event.srcElement.id;
        var j=i.substring(1);
        j=j*1+1;
        i='p'+j;
        document.getElementById(i).focus();}}
    </script>

<form>
<input id="p1" onkeyup="validate(3)" maxlength="3" style="width:1.5em" />-
<input id="p2" onkeyup="validate(3)" maxlength="3" style="width:1.5em" />-
<input id="p3" onkeyup="validate(4)" maxlength="4" style="width:2em" />
<input id="p4" type="submit" />
</form>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron