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

Một mục đó sẽ không hợp lệ Nếu bạn nhấn nút Submit tại thời điểm này, việc xác thực sẽ thất bại, và ứng dụng sẽ hiển thị một hộp thông báo với các thông báo lỗi về định dạng ngày tháng (xem Hình 9-25). | CHAPTER 9 PERFORMING FORM VALIDATION WITH REGULAR EXPRESSIONS Fades out the modal window If this is a new event adds it to the calendar if name event_id .val .length 0 remove false data formData error function msg alert msg .edit-form a contains cancel .live click function event . Now save these changes load http localhost in your browser and then create a new event with bad parameters using the modal window form see Figure 9-24 . 341 CHAPTER 9 PERFORMING FORM VALIDATION WITH REGULAR EXPRESSIONS Figure 9-24. An entry that will fail to validate If you click the Submit button at this point the validation will fail and the app will show an alert box with the error message about the date format see Figure 9-25 . 342 CHAPTER 9 PERFORMING FORM VALIDATION WITH REGULAR EXPRESSIONS Figure 9-25. The error message in an alert box after failing validation After clicking the OK button in the alert box the user will be able to edit her entry without having to repopulate any fields. Summary In this chapter you tackled using regular expressions for form validation. The concepts you learned can be applied to validating any type of data and they will greatly aid you in making sure the information supplied in forms is usable by your applications. In the next chapter you ll learn how to extend the jQuery object both by directly extending the jQuery core and by developing a custom plugin for jQuery. .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.