client-side validation with javascript by daniel yee
TRANSCRIPT
Client-Side Validation with Javascript
by
Daniel Yee
Client-Side Scripting Language
• Javascript
• European Computer Manufacturers Association (ECMA)
• ECMA-262
• Third edition
• Updated Last December 1999
Javascript
• Not a full fledged programming language
• Cannot connect to databases
• Limited interactions to system resources
• Cannot do tasks most web databases require
Common Uses of Javascript
• Validation of <form> data
• Simple interaction with <form> data
• Adding dynamic elements to web page
Benefits of using Javascript
• Faster response then using server-side validation
• Reduction in web-server load
• Reduction in network traffic
• Can be saved as a file - file.js and reused by typing <script type= text/javascript src=“file.js”>
Warning!!!!!!!!!!!!!
• Never rely on client-side validation as the only method of ensuring requirements and constraints
• Javascript can be bypassed by the user through design, error, or configuration
Validating <form> Data
• Simple example for validating a <form> with JavaScript
• Check for whitespace
Batch Error Reporting
• Validation for multiple fields
• Batch error reporting
• Example
Interactive Validation
• Password <form> validation
• Example
Dynamic Elements
• Some implementations not associated with web database applications
• MouseOver
• Prefilled calculations
MouseOver
• Creating a mouseOver Event
• Example
Prefilled Calculations
• Shopping cart updating
• Example
Conclusion
• Javascript is a client-side scripting language
• Can be used for validating forms and enhancing user interactions
• Benefits include improved speed, reduced load, and added features
REMEMBER!!!!!
• NEVER USE AS THE ONLY METHOD TO ENSURE REQUIREMENTS, SECURITY, AND CONSTRAINTS
• WHY?
• BECAUSE IT CAN BE BYPASSED BY THE USER
The End