[thelist] RE: help with form validation using ASP/VBScript

Brooking, John John.Brooking at sappi.com
Tue Mar 1 08:21:37 CST 2005


Ron,

  As others have pointed out, you should consider both client- and
server-side validation, the former for user convenience, and the latter
for security. The links they've given you all look good.
  
  I just wanted to mention one more coding option. This is untested at
the moment, but I'm sure I've done something like it before:
  
  <form action="whatever.asp" method="POST">
  
      ... form fields ...
      
      <input type="submit" value="Submit"
             onClick="return clientSideValidation();">
      
  </form>
  
  The JavaScript function clientSideValidation() should return true if
the validation passed, false if not. This boolean value then is passed
back to the submission button itself. A false value cancels the button's
action, i.e. the form submission. A true value causes it to continue.
This allows you to have all the client-side validation actually on the
client, without a return trip to the server. Then you have to have all
your client-side responses in JavaScript, such as alerts or using the
DOM to change colors or show error messages.
 
Server-side validation is not only for security, but also for those
people who do not have client-side scripting ability. In that case, the
onClick attribute does nothing, so the client-side validation is
skipped.

- John
-- 


This message may contain information which is private, privileged or confidential and is intended solely for the use of the individual or entity named in the message. If you are not the intended recipient of this message, please notify the sender thereof and destroy / delete the message. Neither the sender nor Sappi Limited (including its subsidiaries and associated companies) shall incur any liability resulting directly or indirectly from accessing any of the attached files which may contain a virus or the like.



More information about the thelist mailing list