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!

Validate form for minumum length

Status
Not open for further replies.

gwillr

IS-IT--Management
Nov 4, 2003
267
0
0
CA
Hello

I have a form that validates some information, and subm to DB. I want to add an additional parameter to be validated. THe string should have no less than 8 characters.

Code:
  if len(strEmailAddr) < 8 then
  berror = true
  strNameClass = "clsErrorPrompt"
  strErrMsg = strErrMsg & "Entry Incomplete<br>"

does the syntax look correct on the first line?

Am I looking at this in the right way?


Gary

 
if you cant validate it on the form, it looks ok to me. (on the form is better, as it prevents a round trip to the server)

I assume from you post that there is something odd happening?
 
Just an off-topic addition:
Client-side validation may be better due to less interaction with server, but does not replace server-side validation. In fact, if it comes down to only having one type of validation, you ought to have server-sie validation in place. It is fairly easy to spoof a form POST with information, having client-side opnly validation just tellsthe person who is spoofing what your expecting, allowing them to put in something you weren't expecting (in order to get a DB error, SQL injection attack, etc that will give them more info/access to your system).

-T

barcode_1.gif
 
Agreed, but if you dont have Client side then its not as user friendly, and dont forget, if your form isnt user friendly you'll soon lose visitors and teh main purpose for the site!
 
kalisto,

Excuse my ignorance but how is client side more user friendly? More efficient I understand but what if the user has javascript turned off? If the server catches the errors it doesn't matter what is turned on/off on client side does it? Please elaborate. I really would like to know more. Thanks.

BSL
 
Well if the page has large graphics files or is otherwise large to load.

Of if either the server or client machine is running slow.

Or if the user is on dialup or the pipe is otherwise clogged.

Or whatever.

I think it is polite to catch these things on the client side.

If it is for an intranet then you can count on it running pretty fast and its probably not worth the time to do it both places.

 
Thanks for the input on this one Sheco. Im not sure I agreee that client side is necessarily better. While it is true that it may save time/resources in the cases you had mentioned, but from a intranet sire) perspective, it seems better to use a server side.

The javascript validations you see out there oftenmake use of annoying 'alert' boxes, that many users now equate with pop-ups. They also sound and act similar to all of the windows errors some people seem to get. Using the server-side validaytion and having thge errors returned as red, bold text saves user from clicking "ok" on the alert box. Also, if they have javascript turned off, which I believe is becoming more common, the validation may be rendered useless, defeating your purpose.


Let me know what you think...I find this topic rather interesting!

Thanks!


Gary

 
Hey this debate could run and run, its a choice of personal opinion I guess. I prefer to catch as much as I can client side for a number of reasons including the fact that some of the sites I code have a number of images on, and I used to code for 56k modems, (and there are still a large number of those (and worse) present in the areas I develop for)

Client side validation is not a panacea, and you have to take into account things such as Disability based readers, people disabling JS etc, but unless asked by the client not to validate client side, thats what I'll do

K
 
kalisto,

That's a fair answer and thanks for replying. I guess bottom line is the fact is you have to know who your audience is. If on an intranet...chances are everyone is "forced" through AD, etc to have same settings, browsers etc; therefore, client scripting is definitely the way to go_Otherwise like you said, with the www, do your homework and obviously find out whom the majority of yur audiences is and apply your decision based on demographics, how many, etc.. Kinda an opinionated way to go but definitely worth finding out to make your customer happy. Thanks again for all the inputs. BSL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top