How to make this validation work on cloned inputs
<p>I have this id validation field, i just need to know how i can make the validation and the keydown and keyup functions work on cloned inputs. also inserted data is carrying over to the duplicate fields.</p>

<p>js fiddle- <a href="http://www.jsfiddle.net/dawidvdh/xRh9v/" rel="nofollow">http://www.jsfiddle.net/dawidvdh/xRh9v/</a></p>

<p>Heres the js:</p>

<pre><code>$(document).ready(function() {
    idAmount = [0,1,2,3,4,5,6,7,8,9,10,12,13];
    var idinc =1;
    var id_val;

    jQuery(idAmount).each(function() {
        var index = "id"+idinc++;
        var id_input = "&lt;input class='id' id="+'"'+index+'"'+" "+" maxlength='1' /&gt;";
        id_val = $(this).attr('value');
        jQuery(id_input).appendTo('#id');
    });

    $("#clone").click(function () {
        var clonedObj=$('#id').clone().insertAfter("#id");
        clonedObj.find('.id').each(function(){
           this.id='id' + idinc++;
        });
    });

function Validate() {
    jQuery('#error p').remove();

    var id_val = '';
    $('.id').each(function(){ id_val+=($(this).val());});
    var idNumber = id_val;
    console.log(id_val);
    var correct = true;

    if (idNumber.length != 13 || !isNumber(idNumber)) {
        correct = false;
    }

    var tempDate = new Date(idNumber.substring(0, 2), idNumber.substring(2, 4) - 1, idNumber.substring(4, 6));
    console.log(tempDate);
    var id_date = tempDate.getDate();
    var id_month = tempDate.getMonth();
    var id_year = tempDate.getFullYear();
    var currentYear = (new Date).getFullYear();
    var age = currentYear - id_year;
    var fullDate = id_date + "-" + (id_month + 1) + "-" + id_year;


    if (!((tempDate.getYear() == idNumber.substring(0, 2)) &amp;&amp; (id_month == idNumber.substring(2, 4) - 1) &amp;&amp; (id_date == idNumber.substring(4, 6)))) {
        correct = false;
    }

    // get the gender
    var genderCode = idNumber.substring(6, 10);
    var gender = parseInt(genderCode) &lt; 5000 ? "Female" : "Male";

    // get country ID for citzenship
    var citzenship = parseInt(idNumber.substring(10, 11)) == 0 ? "Yes" : "No";

    // apply Luhn formula for check-digits
    var tempTotal = 0;
    var checkSum = 0;
    var multiplier = 1;
    for (var i = 0; i &lt; 13; ++i) {
        tempTotal = parseInt(idNumber.charAt(i)) * multiplier;
        if (tempTotal &gt; 9) {
            tempTotal = parseInt(tempTotal.toString().charAt(0)) + parseInt(tempTotal.toString().charAt(1));
        }
        checkSum = checkSum + tempTotal;
        multiplier = (multiplier % 2 == 0) ? 1 : 2;
    }
    if ((checkSum % 10) != 0) {
        correct = false;
    };

    // if no error found, hide the error message
    if (correct) {
        jQuery('.id').css("border","1px solid #9A8B7D");


        // clear the result div
        jQuery('#result').empty();
        // and put together a result message
        jQuery('#result').append('&lt;p&gt;South African ID Number:   ' + idNumber + '&lt;/p&gt;&lt;p&gt;Birth Date:   ' + fullDate + '&lt;/p&gt;&lt;p&gt;Gender:  ' + gender + '&lt;/p&gt;&lt;p&gt;SA Citizen:  ' + citzenship + '&lt;/p&gt;&lt;p&gt;AGE:  ' + age + '&lt;/p&gt;');
        jQuery('#status').html("correct");
    }
    // otherwise, show the error
    else {
        jQuery('.id').css("border","1px solid #FF0000");
        jQuery('#status').html("incorrect")
    }

    return false;
}

function isNumber(n) {
    return !isNaN(parseFloat(n)) &amp;&amp; isFinite(n);
}

$('input.id').keydown(function(e){
    if(e.keyCode == 8){
        $(this).val('');
        $(this).prev().val('');
        $(this).prev().focus();
         Validate()
    }
});  

$('input.id').on('keyup', function(){
    if (this.value.match(/\d+/)) {
        var $this = $(this);
        if ($this.next('input').length) {
          $this.next().focus();
        } else {
          Validate()
        }  
    }
});



    $(".id").keydown(function(event) {
        // Allow: backspace, delete, tab, escape, and enter
        if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || 
             // Allow: Ctrl+A
            (event.keyCode == 65 &amp;&amp; event.ctrlKey === true) || 
             // Allow: home, end, left, right
            (event.keyCode &gt;= 35 &amp;&amp; event.keyCode &lt;= 39)) {
                 // let it happen, don't do anything
                 return;
        }
        else {
            // Ensure that it is a number and stop the keypress
            if (event.shiftKey || (event.keyCode &lt; 48 || event.keyCode &gt; 57) &amp;&amp; (event.keyCode &lt; 96 || event.keyCode &gt; 105 )) {
                event.preventDefault(); 
            }   
        }
    });
});
</code></pre>

<p>HTML:</p>

<pre><code>&lt;div id="id"&gt;
&lt;span id="label"&gt;ID NUMBER:&lt;/span&gt;
&lt;span id="status"&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;button id="clone"&gt;clone&lt;/button&gt;

&lt;div id="result"&gt; &lt;/div&gt;
</code></pre>

<p>CSS:</p>

<pre><code>#error {
    color: red;
    border: 1px solid red;
    padding: 5px;
    display: none;
}

#result {
    padding: 20px;
}

.id {
    width:16px;
    height:16px;
    border:1px solid #9A8B7D;
    margin:0;
    float:left;
    text-align:center;
    font-family:'itc_avant_garde_gothic_bookOb',Helvetica,sans-serif;
    font-size:11pt;
    padding:2px;
}
#label {
    float:left;
    font-family:'itc_avant_garde_gothic_bookOb',Helvetica,sans-serif;
    line-height:18px;
    font-size:11pt;
    margin-right:10px;
}
</code></pre>
