Skip to Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
326
If you look in the online examples, you’ll nd a folder called
chapter05-interlude/breakneck. This has all the Break Neck
les, as well as a new utility le, validation-utils.js. Here’s
how you can add validation to your local version of Break Neck Pizza:
Protecting against SQL injection
in your JavaScript
Make sure you have validation-utils.js
1
Add a reference to validation-utils.js in
the Break Neck web form.
2
return (isInteger(s) &&
s.length >= minDigitsInIPhoneNumber);
}
function validatePhone(phoneNumber) {
if ((phoneNumber == null) || (phoneNumber == “”)) {
alert(“Please enter your phone number.”);
return false;
validation-utils.js
<script>
var request...
function
createRequest()
{
...
}
</script>
Here’s just part of the validation-utils.js
le. This le is in the examples, in the
chapter05-interlude/breakneck/ folder.
validatePhone() is the
function you’ll use to
check the phone numbers
entered in the Break
Neck web form.
<html>
<head>
<title>The New and Improved Break Neck Pizza</title>
<link rel=”stylesheet” type=”text/css”
href=”breakneck.css” media=”screen” />
<script type=”text/javascript” src=”ajax.js”> </script>
<script type=”text/javascript” src=”pizza.js”> </script>
<script type=”text/javascript”
src=”validation-utils.js”> </script>
</head>
<html>
.
.
.
</html>
This line makes the
functions in validation-
utils.js available to the
rest of your JavaScript.
Here’s the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content