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.
Printable View
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.
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.
This is a question that is best answered by you and the needs of your application.Quote:
Originally Posted by barianto
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 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.
"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.Quote:
Originally Posted by Moneybucks
I think you are right Hack, :)Quote:
Originally Posted by Hack
And i "feel" to boost my confidence, extra validation step is always necessary. :)
You may want to consider reading up on n-tier design principles.Quote:
Originally Posted by Moneybucks
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...Quote:
Originally Posted by Penagate
Both methods are valid....it pretty much depends on indvidual tastes and application needs.