Client Validation

Last post 08-17-2005 11:35 AM by PLBlum. 3 replies.

Sort Posts:

  • Client Validation

    08-17-2005, 12:21 AM
    • Member
      60 point Member
    • ppsivya
    • Member since 08-17-2005, 4:18 AM
    • Posts 43
    What kinds of validation are appropriately implemented on the client and what kinds are more appropriately implemented on the server. I am using ASP.NET validation controls and I am not sure whether I should enable/disable client side validation

    Thank you
    ppsivya
  • Re: Client Validation

    08-17-2005, 1:52 AM
    • All-Star
      45,864 point All-Star
    • SomeNewKid
    • Member since 08-10-2003, 12:16 AM
    • Western Australia
    • Posts 8,027
    It is important that you do not think client-side validation and server-side validation is a one-or-the-other choice.

    Client-side validation is a nicety for the benefit of the user. He or she will get immediate feedback if some data is invalid. If it were not for client-side validation, the user would have to wait while the page posted back, and then returned with its validation messages.

    Server-side validation is a necessity for the benefit of your application. Even if client-side validation is in place, you must back that up with server-side validation of the same data. It is very easy for a user to intentionally or unintentionally side-step client-side validation. Knowing that, server-side validation becomes a necessity.

    So always use server-side validation. Then, if possible, add client-side validation to improve the user experience. Server-side validation is required; client-side validation is optional.
     
    Alister
  • Re: Client Validation

    08-17-2005, 1:54 AM
    • Participant
      951 point Participant
    • Fredrik K
    • Member since 03-21-2004, 6:14 PM
    • Norway
    • Posts 161
    Client side validation should never be used exclusively, as it is too easy to sidestep (the user just has to disable javascript in his/her browser f.ex). It is great for creating a better, visibly more intuitive user experience by popping up informative error messages next to input fields etc in 'realtime', but you should always have server-side validation to do the 'real' validation after the user has submitted the form. The ASP.NET Validation controls let you do exactly this :)

    Blog: http://iridescence.no
  • Re: Client Validation

    08-17-2005, 11:35 AM
    • All-Star
      30,305 point All-Star
    • PLBlum
    • Member since 06-28-2002, 9:20 AM
    • Boston, MA
    • Posts 5,344
    • TrustedFriends-MVPs
    A few suggestions:
    1. If you create your own validator (including a CustomValidator), always make sure it has server side validation code. The client-side code is optional. If omitted, set the EnableClientScript property to false.
    2. In your Click event method, always test Page.IsValid is true before attempting to save/continue.

    Please see this article for more details including a lot more knowledge on ASP.NET validators: www.aspalliance.com/699.
    --- Peter Blum
    Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
    www.PeterBlum.com
Page 1 of 1 (4 items)