0

Hi I have below form field to enter Tax Id. I was wondering how can i split it so that first box takes only 2 digits an than second 7 with "-" i.e 44-2234233

    <div class="form">
        <label class="form1" for="o_taxId">Tax Id</label>
        <input type="number" class="medium" id="o_taxId" name="taxId" />
    </div>

Please help. Thanks

J. Davidson
  • 3,297
  • 13
  • 54
  • 102

1 Answers1

0

With JQuery you can do this:

<div class="form">
    <label class="form1" for="o_taxId">Tax Id</label>
    <input type="number" class="medium" id="o_taxId" name="taxId" size="2" maxlength="2" />
    <input type="number" class="medium" id="o_taxId2" name="taxId2" size="7" maxlength="7" />
</div>
<script>
$('#o_taxId').bind('input', function() { 
    var length1 = $(this).val().length;
    if (length1 === 2) {
        $('#o_taxId2').focus();
    }
});
</script>

this swaps focus autocratically to the second field when you type in the first, but if you don't need that you can remove the script.

NatureShade
  • 2,187
  • 1
  • 19
  • 27