How to validate textbox
<p>i have problem with my program. what i want is to validate the textbox if it is equal to data that i get from my database. if it's equal then set focus if not the textbox should be null and and will not able to enter. this is my sample code.Any help is very much appreciated. Thank you.  </p>

<pre><code>function sequence(varid) {

    var a = varid.indexOf("/")
    var b = varid.slice(0, a);
    b = parseInt(b)
    c = (b + 1)
    var f = varid.slice(a);

    if (window.event.keyCode == 13 || window.event.keyCode == 10) {

        var lot_number = document.getElementsByName("lot_number")[b].value;
        var lot_number_scan = document.getElementsByName("lot_number_scan")[b].value;

        var counting = document.getElementsByName("lot_number_scan");

        counting = counting.length;

        var newid = c + f
        if (c == counting) {
            document.getElementById("issued_by").focus();
        } else {
            lot_number_scan = lot_number_scan.replace(/(LO)/g, "-LO");
            lot_number_scan = lot_number_scan.replace(/-/, "");

            var check = (new RegExp(lot_number_scan, "gi").test(lot_number));

            if (check == true) {
                document.getElementById(newid).focus();
            } else {
                document.getElementsByName("lot_number_scan")[b].value = '';
                document.getElementsByName("lot_number_scan").focus();
            }

            document.getElementById(newid).focus();
        }
    }
}
&lt;/script&gt;
</code></pre>

<hr>

<p>sorry for late reply.. what happen when i run that codes is, still enter though the entered data is not equal or not the same with the other data sorry if I'm not good in explanation i will give sample hope this can help.</p>

<p><strong>Data from database</strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>Texbox</strong><br>
123456828 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;123456828<br>
152685689 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;123456828        </p>

<p>Save Button</p>

<p><strong>Data from database</strong> is just a display data that i post after filtering the sequence of  data. 
<strong>Textbox</strong> I scan barcode to input data.</p>

<p>If the entered data in the textbox is matches to the display data it automatically enter the second textbox and ready to scan again Im ok with that, What i want to happen is when the entered data is not match is should not enter to the second textbox or save button also when it enter wrong data it should automatically erase the wrong entered data and ask for correct one. hope you can understand what i want to happen I'm new in coding and self study so your help is very much needed and thank you s much..</p>
