473,394 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Repost: Validation with JavaScript and SQL Server db vs. Array list values

Hello,

I know, using client-side validation to validate form data by looping
through a SQL Server table isn't the best way in terms of security.

But, is there a way to compare the form object value against
values in a flat file, like with arrays? I have a flat file of 1300
values I'd like to be able to use as a comparator against the value I
grab from the form to validate the input.

Thanks for any examples, help or suggestions,
KP

Feb 13 '06 #1
4 1951
Can AJAX work for your requirements?
you can use cleint-side javascript to validate the form data, and use
ajax to compare them with the data in sql-server or server side
servlet, jsp.....

hope I didn't misunderstand what you want

Feb 13 '06 #2
Actually, what would suffice for me at this point would be to do the
form validation using text (data) file. 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.

Peter, could you show me or point me to an example of how I would be
able to implement AJAX into my struts framework?

Thanks,
KP

Feb 13 '06 #3
Kermit Piper wrote:
Hello,

I know, using client-side validation to validate form data by looping
through a SQL Server table isn't the best way in terms of security.

But, is there a way to compare the form object value against
values in a flat file, like with arrays? I have a flat file of 1300
values I'd like to be able to use as a comparator against the value I
grab from the form to validate the input.


Probably the fastest way to validate a large number of values is to use
an Object object and have your 1300 values as properties of the object,
then use for..in, e.g.:
var validNames = {
name0001 :'',
name0002 :'',
name0003 :'',
...
name1299 :'',
name1300 :''
};

Then you can check:

if ( someEntry in validNames ){
// someEntry is valid
}
However you need to weigh up the time spent downloading the object to
the client vs the time that might be spend going back to the server and
validating there in the first place.

I have also successfully used an array where an index is created based
on the first character of each string, then use the first character of
the entered string to get the index. Loop through the array from that
point grabbing only the elements that match the entered text and present
them as options. Users then get an ever-diminishing list of options to
select.

Even with a poor distribution of first letters, the lookup loop is
usually still very fast.
--
Rob
Feb 13 '06 #4
RobG wrote:
Kermit Piper wrote:
Hello,

I know, using client-side validation to validate form data by looping
through a SQL Server table isn't the best way in terms of security.

But, is there a way to compare the form object value against
values in a flat file, like with arrays? I have a flat file of 1300
values I'd like to be able to use as a comparator against the value I
grab from the form to validate the input.


Should have mentioned that my suggested method has zero security,
server-side validation will still be essential.
[...]
--
Rob
Feb 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
16
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
2
by: Dnna | last post by:
I have a table which is bound to an Internet Explorer XML data island. I'm using ASP.NET's client-side validators for an input field in the table. The problem is that if the input fields are in...
4
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all...
1
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
1
by: Sergei Riaguzov | last post by:
Hi. I haven't written in PHP too much so I think I should ask how my problem can be solved "the right way". I'm having some forms (actually this is not my code, and actually I haven't got it yet...
3
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.