0

I would like to ask you if is possible to use function "if" "indexOf" to using if strings from a file (like .txt file contains a words).

I'm using if indexOf to checking if string is exists after typing to input from HTML code.

function checkBarcode()
{

var barcode  =  document.getElementById("barcodedata").value;       

if (barcode.indexOf('RMA') > -1) {
} else if (barcode.indexOf('sp') > -1) {

} else if (barcode.indexOf('D') > -1) {

} else if (barcode.indexOf('J') > -1) {

} else {
alert("message");

funcinvalid();
}

}

Thanks for helping.

  • Yes, you can store them in a .js file, though the questions smells more like [XY](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem/66378#66378) problem ..? – Teemu Jan 09 '19 at 07:27
  • My apologize, yes. I'm not sure how can I used this. This not gonna so easy right? Like exchange a string wtih "var" of file? – user2622950 Jan 09 '19 at 07:37
  • Are you searching the word in file content? Then try to get the content like this [see this answer](https://stackoverflow.com/questions/31746837/reading-uploaded-text-file-contents-in-html). Then you can use the `indexOf` function. – Madhavan.V Jan 09 '19 at 07:38
  • If you described the result you actually want and the conditions, then we could solve the problem you're having. – Teemu Jan 09 '19 at 08:06

0 Answers0