Split boxes to enter number for same Id

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

Answers


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.


Need Your Help

Generating Pdf from webpage in asp.net

c# asp.net pdf invoice

Could you give me some recommendations on free/Openspurce library etc that could be integrated on asp.net application to Generate Pdf out of Html fragments. I will be generating Invoices that is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.