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. \[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").value; var lot_number_scan = document.getElementsByName("lot_number_scan").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").valuehttp://stackoverflow.com/questions/15848035/= ''; document.getElementsByName("lot_number_scan").focus(); } document.getElementById(newid).focus(); } }}</script>\[/code\]