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.

332<br />

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

Figure 9-19. Validating the hour section of the date string<br />

To validate the minutes, you match a colon <strong>and</strong> exactly two digits: /^(\d{4}(-\d{2}){2}<br />

(\d{2})(:\d{2}))/ (see Figure 9-20).<br />

Figure 9-20. Validating the minutes section of the date string<br />

Finally, repeat the pattern for the minutes to match the seconds, <strong>and</strong> then use the dollar sign<br />

modifier to match the end of the string: /^(\d{4}(-\d{2}){2} (\d{2})(:\d{2}){2})$/ (see Figure 9-21).<br />

Figure 9-21. Validating the seconds section of the date string <strong>and</strong> completing the pattern

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

Saved successfully!

Ooh no, something went wrong!