Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8354219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:29:16+00:00 2026-06-09T09:29:16+00:00

I have text file. there around 1000 lines in it, each line contains a

  • 0

I have text file. there around 1000 lines in it, each line contains a 8 letter alpha numeric word for example my text file looks like this

TEST1234
T1E2A334
12RR8912

and so on. this file is located on the server in a folder called TestCodes

Now I have an html file called test.html where in this file I have input textbox where the user enters the testcode he/she has with them

I have button called Verify. when this input button is clicked I want to check the user inputed value against the contents in the text file.

If the testcode exists in the text file then display a button called Procced if not display an error message called invalid.

I know how to write the if condition but I have no idea how to check it against the text file

HTML

<div class="user-input">
    <input type="text" name="test-code" id="test-code" value="" />
    <input type="submit" value="Verify Code" name="verify-code" id="verify-code" />
</div>
<div id="TestRegister">
    <form id="club" action="/Proceed.html" method="post" autocomplete="off">
        <input type="submit" value="Proceed Registration" name="proceed-register" />
    </form>
</div>
<div id="TestError">
    <span>Please check the code again, its not valid</span>
</div>

JavaScript

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function () {
    $("#TestRegister").hide();
    $("#TestError").hide();

    $.get("testcodes.txt", function (data) {
        var lines = data.split("\n");

        // this is where I am stuck. how to pass the above to ARRAY
        $("#verify-code").click(function (e) {
            e.preventDefault();
            if ( /* here I need to check against the user input value, if they are equal */ ) {
                $("#TestRegister").show();
                $("TestError").hide();
            } else {
                $("#TestRegister").hide();
                $("TestError").show();
            }
        }
        });     


</script>

How can I pass text from testcodes to an Array and then check the user input value against this array? If the user input value is present in the array then I want to show #TestRegister, and if not, or if the input value is blank or null, show #TestError.

Thanks and appreciate any tips.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:29:18+00:00Added an answer on June 9, 2026 at 9:29 am
    var lines;
    
    $(document).ready(function () {
        $("#TestRegister").hide();
        $("#TestError").hide();
    
        $.get("testcodes.txt", function (data) {
            lines = data.split("\n");
        });
    
        $("#verify-code").click(function (e) {
            e.preventDefault();
    
            if (lines.indexOf($("#test-code").val()) !== -1 && $("#test-code").val().length == 8) {
                $("#TestRegister").show();
                $("TestError").hide();
            } else {
                $("#TestRegister").hide();
                $("TestError").show();
            }
    
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file apple banana Now you watch closely there is blank
I have a text file that looks like this: value1 value2 value3 There are
I have java source code in a text file. There has to be entered
I have text file with something like first line line nr 2 line three
I have Text file that contains data separated with a comma , . How
If I have a script that writes 1000 lines to file and then continues
I have a text file that contains references to variables and lets a user
I have a huge line-separated text file and I want to make some calculations
I'm taking in a text file with around 60,000 lines of point coordinates, (I
I have a tcsh script that generates a text file. One of the lines

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.