Results 1 to 9 of 9

Thread: Double Validate

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Double Validate

    Hi,

    I know we all do on the spot validate (keypress event, change event, validate event, etc). But before data collected save to databases should we do validate again?

    Thanks.

  2. #2
    Lively Member Moneybucks's Avatar
    Join Date
    Apr 2006
    Location
    Kingston Upon Thames -UK
    Posts
    123

    Re: Double Validate

    I only ever validate just before the data is entered into the database, just because the user might see his/her error beforehand.

    The answer though is no, so long as you are certain that invalid data cannot be entered into the input controls. If for example, you validate a textbox on Change, invalid data can never be entered into that box, so it seems a waste of time to validate again.
    If, somehow, I help you, please rate the post using the scales icon in the left bar <---- .

    Please Use Naming Conventions in your projects! ------\/
    http://www.visibleprogress.com/vb_na...onventions.htm

    Me to Brother
    -Hey, look at this avater I made in about 5 seconds
    -What, morrisons?
    -AGHHHHHH

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Double Validate

    Quote Originally Posted by barianto
    Hi,

    I know we all do on the spot validate (keypress event, change event, validate event, etc). But before data collected save to databases should we do validate again?
    This is a question that is best answered by you and the needs of your application.

    Do you feel an extra validation step is necessary? If yes, then do so. If no, then do not.

    The answer to this question will not be the same from one app to another.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Double Validate

    I consider it a bad practice to rely on the user interface to validate data that's going into a database. Application layers should perform their own validation independently of each other.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Double Validate

    Quote Originally Posted by Moneybucks
    The answer though is no, so long as you are certain that invalid data cannot be entered into the input controls.
    "Invalid data", as far as the particular database is concerned, might be missing data. For instance, in a POS application, the amount paid is verified as a valid currency amount, but "no entry" would be invalid for a payment operation, so that would have to be verified at the time the data is saved.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Double Validate

    Quote Originally Posted by Hack
    This is a question that is best answered by you and the needs of your application.

    Do you feel an extra validation step is necessary? If yes, then do so. If no, then do not.

    The answer to this question will not be the same from one app to another.
    I think you are right Hack,
    And i "feel" to boost my confidence, extra validation step is always necessary.

  7. #7
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Double Validate

    Quote Originally Posted by Moneybucks
    I only ever validate just before the data is entered into the database, just because the user might see his/her error beforehand.

    The answer though is no, so long as you are certain that invalid data cannot be entered into the input controls. If for example, you validate a textbox on Change, invalid data can never be entered into that box, so it seems a waste of time to validate again.
    You may want to consider reading up on n-tier design principles.

  8. #8
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Double Validate

    Quote Originally Posted by Penagate
    I consider it a bad practice to rely on the user interface to validate data that's going into a database. Application layers should perform their own validation independently of each other.
    I agree this...I always do the validation just before the save takes place...I dont write any validation in the Lost_Focus or Change event, I validate the input only when the Save Button is pressed...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Double Validate

    Both methods are valid....it pretty much depends on indvidual tastes and application needs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width