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.

x<br />

■ CONTENTS<br />

■Chapter 9: Performing Form Validation with Regular Expressions .....................311<br />

Getting Comfortable with Regular Expressions .............................................................311<br />

Underst<strong>and</strong>ing Basic Regular Expression Syntax................................................................................. 311<br />

Drilling Down on the Basics of Pattern Modifiers................................................................................. 316<br />

Getting Fancy with Backreferences...................................................................................................... 318<br />

Matching Character Classes................................................................................................................. 320<br />

Finding Word Boundaries ..................................................................................................................... 323<br />

Using Repetition Operators................................................................................................................... 323<br />

Detecting the Beginning or End of a String .......................................................................................... 324<br />

Using Alternation .................................................................................................................................. 324<br />

Using Optional Items............................................................................................................................. 325<br />

Putting It All Together........................................................................................................................... 326<br />

Adding Server-Side Date Validation...............................................................................328<br />

Defining the Regex Pattern to Validate Dates....................................................................................... 328<br />

Adding a Validation Method to the Calendar Class............................................................................... 333<br />

Returning an Error if the Dates Don’t Validate...................................................................................... 334<br />

Adding Client-Side Date Validation................................................................................338<br />

Creating a New JavaScript File to Validate the Date String.................................................................. 338<br />

Including the New File in the Footer..................................................................................................... 339<br />

Preventing the Form Submission if Validation Fails ............................................................................. 339<br />

Summary .......................................................................................................................343<br />

■Chapter 10: Extending <strong>jQuery</strong>..............................................................................345<br />

Adding Functions to <strong>jQuery</strong>............................................................................................345<br />

Adding Your Date Validation Function to <strong>jQuery</strong>................................................................................... 345<br />

Modifying the Include Script................................................................................................................. 348<br />

Modifying the Initialization Script......................................................................................................... 348<br />

Adding Methods to <strong>jQuery</strong> .............................................................................................350

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

Saved successfully!

Ooh no, something went wrong!