javascript - How to validate textbox -
i have problem program. want validate textbox if equal data database. if it's equal set focus if not textbox should null , and not able enter. sample code.any appreciated. thank you.
function sequence(varid) { var = 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(); } } } </script> sorry late reply.. happen when run codes is, still enter though entered data not equal or not same other data sorry if i'm not in explanation give sample hope can help.
data database texbox
123456828 123456828
152685689 123456828
save button
data database display data post after filtering sequence of data. textbox scan barcode input data.
if entered data in textbox matches display data automatically enter second textbox , ready scan again im ok that, want happen when entered data not match should not enter second textbox or save button when enter wrong data should automatically erase wrong entered data , ask correct one. hope can understand want happen i'm new in coding , self study needed , thank s much..
i think can use jquery , in case can check , set value in different jquery selectors.
for example:
$('input[type=text][id="textfieldid"]').val('myvaluetobeset'); hope might you.
Comments
Post a Comment