Data-Entry 43Validation CHAPTER …. Give users a field (Web hosting)
Data-Entry 43Validation CHAPTER …. Give users a field in which to enter data and you can be sure that some users will enter the wrong kind of data. Often the mistake is accidental a slip of the pinkie on the keyboard; other times, users intentionally type the incorrect entry to test the robustness of your application. Whether you solicit a user s entry for client-side scripting purposes or for input into a server-based CGI or database, you should use JavaScript on the client to handle validation of the user s entry. Even for a form connected to a CGI script, it s far more efficient (from the perspective of bandwidth, server load, and execution speed) to let client-side JavaScript get the data straight before your server program deals with it. Real-Time Versus Batch Validation You have two opportunities to perform data-entry valida tion in a form: as the user enters data into a form and just before the form is submitted. I recommend you take advan tage of both of these opportunities. Real-time validation triggers The most convenient time to catch an error is immediately after the user makes it especially for a long form that requests a wide variety of information. You can make the user s experience less frustrating if you catch an entry mis take just after the user enters the information: his or her attention is already focused on the nature of the content (or some paper source material may already be in front of the user). It is much easier for the user to address the same infor mation entry right away. A valid question for the page author is how to trigger the real-time validation. Backward-compatible text boxes have two potential event handlers for this purpose: onChange and onBlur. I personally avoid onBlur event handlers, especially ones that can display an alert dialog box (as a data-entry vali dation is likely to do). Because a good validation routine brings focus to the errant text box, you can get some odd behavior with the interaction of the focus()method and the In This Chapter Validating data as it is being entered Validating data immediately prior to submission Organizing complex data-validation tasks ….
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.