Auto focus textfield : TextField : Form Control JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Form Control » TextField »

 

Auto focus textfield



<html>
<head>
<SCRIPT LANGUAGE="JavaScript"
function autofocus(field, limit, next, evt) {
    evt = (evt? evt : event;
    var charCode = (evt.charCode? evt.charCode : ((evt.keyCode? evt.keyCode : 
        ((evt.which? evt.which : 0));
    if (charCode > 31 && field.value.length == limit) {
        field.form.elements[next].focus();
    }
}
</SCRIPT
</head>
<body>
<form>
Credit Card Number:
<input type="text" name="cc1" size="5" maxlength="4" 
    onkeypress="return numeralsOnly(event)" 
    onkeyup="autofocus(this, 4, 'cc2', event)">&nbsp;&nbsp;
<input type="text" name="cc2" size="5" maxlength="4" 
    onkeypress="return numeralsOnly(event)" 
    onkeyup="autofocus(this, 4, 'cc3', event)">&nbsp;&nbsp;
<input type="text" name="cc3" size="5" maxlength="4" 
    onkeypress="return numeralsOnly(event)" 
    onkeyup="autofocus(this, 4, 'cc4', event)">&nbsp;&nbsp;
<input type="text" name="cc4" size="5" maxlength="4" 
    onkeypress="return numeralsOnly(event)">
</form>    
</body>
</html>


           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Form Control
» TextField