SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 207 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"

If your app uses a

to gather information, you??™ll probably want to try and validate that information to make sure
that what the user is filling in is reasonable in some way. Hence the convention that an * next
to a bit of a form means ???this part is mandatory; you must fill it in.??? It??™s equally important that
if you want the information you receive to be in a certain format you have your app enforce
that format. This is what validation is all about: having your app check what the user types to
confirm that it??™s what you were expecting. If you??™re asking users for the number of chickens
they own, it??™s a good idea to check that what they type in is a number instead of ???I don??™t own
any chickens,??? or something similar.
Validation helps with data quality. It also means that later bits of your programs can assume
that the data they have is valid; for example, if you want to sell the user another chicken, you can
write ???How would you like to own ($chickens + 1) chickens???? without having to worry about
what happens if you try to add 1 to what the user typed in. Validation is important.
Since this is a book about document object model (DOM) scripting, you might think that
you??™ll launch immediately into JavaScript, but that??™s not the case. One of the important points
about validation on the Web is that you must not just use JavaScript to do it. Users might have
JavaScript turned off; they might be using their cell phone; they might be demonstrating your
magnificent chickenbuyer.


Pages:
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219