02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

?><br />

CHAPTER 9 ■ PERFORMING FORM VALIDATION WITH REGULAR EXPRESSIONS<br />

You can test the validation <strong>by</strong> entering a bad entry into the form at http://localhost/admin.php (see<br />

Figure 9-22).<br />

Figure 9-22. An entry with bad date values that should fail validation<br />

■ Note You use http://localhost/admin.php because the only reason your server-side validation will be<br />

invoked is if the user has JavaScript disabled. In that case, the modal windows would not function, <strong>and</strong> the user<br />

would be brought to this form. In situations where JavaScript is enabled, the server-side acts as a double-check<br />

<strong>and</strong> an additional security measure against mischievous users.<br />

After this form is submitted, the app will simply output the error message <strong>and</strong> die (see Figure 9-23).<br />

The calendar application is designed for users with JavaScript enabled; you use this approach to prevent<br />

the app from displaying errors.<br />

337

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!