I have three inputs for telephone numbers that each have its length of 4,8,4 repectively. I handle the focus of mouse through jQuery when maxlength of input field is reached then focus/jump to the next field.
I also want to do a beside focus to count the digits in each field if they are less then maxlength then append zeros on the left side to make it equal to the maxlength of respective input fields when we echo the entered field. e.g if in first input someone enters only two digits like 47
then the output should be 0047
with two appended zeros on the left side after echo.
Here is my HTML:
<form>
<input type="text" name="area_code" id="area_code" maxlength="4" size="3" /> -
<input type="text" name="number1" id="number1" maxlength="8" size="8" /> -
<input type="text" name="number2" id="number2" maxlength="4" size="3" />
</form>
here is the jquery
<script type="text/javascript" src="js/jquery.autotab-1.1b.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#area_code, #number1, #number2').autotab_magic().autotab_filter('numeric');
});
</script>