View Full Version : Server Side Validation
Thatguy2001au
08-13-2003, 01:15 PM
Hey guys
I'm looking to do some Server Side validation on an order form which will be filled out users of my site.
I have a couple of fields which must only have numeric values in them such as postcode etc because i have them set as Integer values in the SQL Server Database.
At the moment, my form sends everything back to itself and i do a check within the page to see if the 'Submit Order' button has been Clicked. If so, I then place the values of the fields into variables.
Does anyone have some validation script handy which will allow me to check for the above, and if fields are left empty when they shouldn't have been, and the allow me to give an error message to the user?
Is it possible to collect all the errors and then display them all at the top of the page in point form?
Any help will be greatly appreciated.
Thatguy
Doesn't this give you the info you need?
http://www.codingforums.com/showthread.php?s=&threadid=24391&highlight=flag
Displayen them on to in pointform is quite easy. After each error, you add something to a stringvariable
like
errors=errors & "<br />- New erromessage"
and then after all checks, you response.write(errors)
or you can use listtags whenyou add new erromessages to errors
Thatguy2001au
08-13-2003, 02:17 PM
it gives me most and your reply showed me how to list each error one after the other.
The only other thing, is how do i check to see if the user has entered only a numeric value into a field where i only want numbers entered???
And do i then need to use 'cInt' to convert that into an Integer before i add it to the database?
And one more thing, I am using a function which sends the parameters to a SP to do the Insert. Cause there are so many parameters, how do i put the parameters onto 2 lines instead of the one? I know it's simple, i just can't think of it right now.
eg: FcnAdd (blah1, blah2, blah3, blah4, blah5, blah6) to
FcnAdd (blah1, blah2, blah3
blah4, blah5, blah6)
Thanks
Thatguy2001au
08-13-2003, 02:19 PM
Sorry, disregard the numeric value checking question on the last post.
Roy Sinclair
08-13-2003, 05:15 PM
To split a line into two lines use the VB line continuation character which is _. Just place it at the end of the first line.
And do i then need to use 'cInt' to convert that into an Integer before i add it to the database?
Depends. If you are sure it are integers, then not, but it doesn't hurt to have the CInt() inthere, i suppose. Just to make sure.
You might want to check for . an , in it. Since some country's (like belgium) have values in this format 1.236.235,125
So if i'd enter 1.005 , then this is an integer --> 1005
But CInt(1.005) = 1 if your hosted on a server with american settings.
But an american could enter the same for 1,005 --> 1
So if the expected values (like our IQ or so ) are lower then 1000, you can deal with that yourself to get the integervalue, but if they are real big ...
whammy
08-13-2003, 11:50 PM
Keep in mind that IsNumeric() won't catch things like
1,000,000+
-34.6
etc.
For that you could use my IsDigits() function...
http://www.solidscripts.com/downloads/functions.txt
Thatguy2001au
08-14-2003, 07:46 AM
Thanks guys
You have all given me things to think about. I appreciate the text file with the validator functions too. Should make my job much easier.
Seems you guys got an answer for any question. Makes mine, and i am sure alot of others jobs much easier.
Thanks
Thatguy
great link, Whammy.
(I gotta master these regex's when i find the time)
Seems you guys got an answer for any question.
Ha. "a fool may ask more questions in an hour than a wise man can answer in seven years" so put us to the test :D
(probably, i'ml one of the fools :rolleyes: )
whammy
08-14-2003, 07:49 PM
Thanks - I've been working on those functions for quite awhile now - and they all seem to be pretty solid. Might as well share them. :)
Thatguy2001au
08-15-2003, 06:05 AM
I'm glad you did. they are great. they have certainly made things much easier and given me better control of any validation that i need to do.
thanks
thatguy
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.