TAILIEUCHUNG - Tương tác giữa PHP và jQuery - part 34

ở rộng xác nhận phần tháng của Thông báo chuỗi ngày đó các phần tháng và ngày là giống nhau: một dấu nối tiếp bởi hai chữ số. Điều này có nghĩa bạn chỉ có thể lặp lại mẫu tháng phù hợp để xác nhận ngày bằng cách sử dụng một nhà điều hành lặp lại sau khi nhóm này: / ^ (\ d {4} (- \ d {2}) {2}) / (xem hình 9-18 ). | CHAPTER 9 PERFORMING FORM VALIDATION WITH REGULAR EXPRESSIONS Figure 9-17. Expanding the validate month section of the date string Notice that the month and date sections are identical a hyphen followed by two digits. This means you can simply repeat the month-matching pattern to validate the day using a repetition operator after the group A d 4 - d 2 2 see Figure 9-18 . Regular Expression Demo C j O C1 1 http localhost 1 Regular Expression Demo 2010-01-14 12 00 00 Saturday May 14th at 7ptn 02 03 10 10 00pm 2010-01-14 102 00 00 Pattern used d 4J - i 2 2 Figure 9-18. Adding the day part ofthe date string to the pattern Now match a single space and the hour section A d 4 - d 2 2 d 2 see Figure 9-19 . Note Make sure that you include the space character. The shorthand class s shouldn t be used because new lines and tabs should not match in this instance. 331 CHAPTER 9 PERFORMING FORM VALIDATION WITH REGULAR EXPRESSIONS ft o o Regular Expression Demo j o- nttp localliost uZOT G poo le Q j Regular Expression Demo 2010-01-1472 00 00 Saturday May 14th at 7pm 02 03 10 10 00pm 2010-01-14 702 00 00 Pattern used d 4 i- d 2 2 d 2 Figure 9-19. Validating the hour section of the date string To validate the minutes you match a colon and exactly two digits A d 4 - d 2 2 d 2 d 2 see Figure 9-20 . Regular Expression Demo k I C C_ O http localhost i-iHT CQ 3le _ I Regular Expression Demo rr 2010-01-14 12 00 00 Saturday May 14th at 7pm 02 03 10 10 00pm 2010-01-14 102 00 00 Pattern used d 4 - d 2 H2 d 2 d 2 Figure 9-20. Validating the minutes section of the date string Finally repeat the pattern for the minutes to match the seconds and then use the dollar sign modifier to match the end of the string A d 4 - d 2 2 d 2 d 2 2 see Figure 9-21 . ft o o Regular Expression Demo 3 li-Ù http localhost G pop le 1 j Regular Expression Demo 2010-01-14 12 00 00 Saturday May 14th at 7pm 02 03 10 10 00pm 2010-01-14 102 00 00 Pattern used d 4 - d 2 2 d 2

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.