Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form validation using text (data) file

Status
Not open for further replies.

cyberbob2

Programmer
Nov 13, 2003
32
0
0
US
Hello,

I have a finite list of values that I need to use to validate what users enter as a valid number. I would like to simply put these numbers into a flat file (txt or csv) and be able to use a javascript to use this file to compare the value that the user entered with a match in the file. Is this possible, and if so, can someone please show me an example. Any help would be greatly appreciated.

Thanks,
CB
 
If the file resides on the server, you'll have to use something server-side to load the data. If you put the data into a Javascript array, you can load it as an external JS file and use it that way, but that's the only universally workable method.

You could look into AJAX, but I've read some things recently that make it sound like it might be the next "hot" item to go cold because of the load it puts on servers, lack of security, and other real and potential problems.

Lee
 
...lack of security, and other real and potential problems
I see. So you are saying we shouldn't use AJAX techniques because of potential problems? I think the "things" you've read may just be that... "things" - things that are being taken out of context and misunderstood.

For the record... AJAX techniques are no more or less secure than using a regular FORM on the page to submit data (that debunks the "lack of security").

Any web application can put excessive load on the server - and it's the responsibility of the Architect to design a solution (and to specify the environment) in such a way that this is not a problem. AJAX techniques do not change this fact... as a developer you have to be responsible for choosing the right way to implement a technology.

Maybe you would have been better off saying that AJAX techniques (when used naively and inappropriately) can lead to problems with server load and with security - but no more (or less) than any other technique on the internet today.

Of course... some reference to your sources of "things" that you have read would allow us to debate this in more depth.

Harry
 
I wrote that response to answer a question, not get into a debate with someone new to Tek-Tips. While AJAX is a possible solution, it also seems to be the newest, hottest, latest whatever to be hyped. I've seen WAY too many "new, hot" technologies be promoted for a short period of time before they actually fell into the position that they fit in the computer world. My point was to suggest another approach than using client-side Javascript, and if AJAX is to be considered, good OBJECTIVE research should be done first to find the pros and cons.

AJAX, like many other things, has attracted a lot of religious fervor for and against it, with rants and raves on either side that are not necessarily rational or accurate. It's not the first thing to have this happen, won't be the last.

From experience, I think something server-side would best fit what the original question asked. That keeps the control away from the client computer and lets the script designer choose how the data is handled.

Lee
 
Ha!

Don't you know that Case Tools made all computer programmers obsolete way back in 1992?

Also remember that Netscape replaced your operating system in 1996?

Oh, and the NetPC replaced your home computer in 1998... just as Java was taking over the world.

Don't forget that XML will mow your lawn and pick up the kids after school.



Hey, has anyone seen any of the "switch grass" that the president said would help break our addiction to oil?

/next
//big
///thing
 
Please no more AJAX martyrs..... I don't think I can handle another one.......



Do I use AJAX? Yes, very sparingly and only where appropriate.

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
Sheco, you got XML to pick up the kids? I thought that was a mythical function. Lawn mowing was easy with a well defined data grid to show the mow path but picking up the kids just had too many variables.

Damn, I need to get that working now.



Seriously though cyberbob2, you can setup your array in a .js file as trollacious said above or you can use server-side code to read the file and dump it into a javascript array. Let us know which approach you want to go with and maybe we can help you out with some code.
I have some ASP/VBScript code to read the file and dump it into a javascript array if you need.


Stamp out, eliminate and abolish redundancy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top