Choose form validation style carefully
In web applications, validation of user input can be done with two different tools :
- scripting code executed by the browser (javascript, for example)
- regular java code executed by the server, as part of the web application
- cannot be disabled by a change in browser preferences
- executes only after the SUBMIT button is pressed
- validates all fields of the form as one unit
- if an error is detected, a new web page is displayed, with an appropriate error message
- can be disabled by a change in browser preferences
- can be initiated in two ways : after the SUBMIT button is pressed, or after an input field has changed
- if executing after SUBMIT is pressed, the form's data is POST-ed to the server only if validation is successful
- if an error is detected, a pop-up dialog box is displayed
Browser validation seems most useful for :
- low bandwidth environments
- forms with a large number of fields, each validated as it is input
Many prefer to treat server validation as mandatory and browser validation
as optional, either as a performance optimization or as the preferred user
experience. If both are implemented, then this will usually represent significant
code repetition.
See Also :
Would you use this technique?
Add your comment to this Topic :
|