TAILIEUCHUNG - Validating Against a List of Choices

Xác nhận đối với một Danh sách các lựa chọn Có lần khi một giá trị nhập vào một biểu mẫu phải phù hợp với một trong nhiều lựa chọn. Ví dụ, nếu hình thành một yêu cầu người dùng nhập vào một cụ thể màu đỏ, vàng, hoặc màu xanh-và người dùng vô tình đi vào que hoặc yullow thay vào đó, điều quan trọng để có thể phát hiện lỗi khi xác nhận hình thức. | Validating Against a List of Choices There are times when a value entered into a form must match one of several choices. For example if a form asks the user to enter a specific color red yellow or blue and the user accidentally enters rod or yullow instead it s important to be able to detect that error when validating the form. If you re going to compare data entered against a list of choices obviously you must define that list first. In ActionScript an array can include a list of choices. The validation process is simply a matter of comparing the entered data against the values in the array to see if there s a match. In this exercise we ll create another validation routine this one to compare what s entered in the state_ti instance against an array of state names. TIP It s best to have users do as little manual data entry as possible. Instead of requiring the user to input data that matches one of several choices you would be better off providing a drop-down list from which the user could choose a value a method that eliminates the need for data validation. In some applications however this is impossible for example in a quiz application that contains a list of answers you don t want users to be able to access. In such cases there s no way to avoid manual validation. 1. Open . We will continue building on the project from the last exercise. 2. With the Actions panel open select Frame 1 on the Actions layer and add the following function definition at the end of the current script 3. 4. function validateState 5. 6. var states Array California Indiana North Carolina Oklahoma 7. 8. var matchFound Boolean false 9. 10. for var i 0 i i 11. 12. if states i 13. 14. matchFound true 15. 16. break 17. 18. 19. 20. 21. 22. if matchF ound 23. 24. Please enter a valid state. 25. 26. color 0x990000 27. 28. 29. 30. 31. The validateState function validates the data entered into the state_ti instance. The first .

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.