0

In an HTML form could I type something and see if it matches against something in a text file? If so, how would I go about doing this?

2 Answers2

1

You could use an ajax request to load a JSON file from your server

eg if you are using jQuery

$.getJSON( "my-json-file.json", function( data ) {
    console.log(data.property);
    console.log(data.anotherProperty);
});

this would assume you have a JSON file in your server root folder called my-json-file.json with this structure

{
    "property": "the data you want to store"
    "anotherProperty": 999999
}

Be aware that you would have to wait for this JSON file to be loaded first before you could access and use the data in it. Eg the function with the 2 console logs in it will only be called once the JSON file is loaded

Matthew
  • 952
  • 7
  • 20
0

In HTML and Javascript fortunately you can't interact with files in your file system. I suggest you to use Ajax to download the information and compare the result with the inputs.

Gerviba
  • 3
  • 2
  • 4