Đỉnh NGUYỄN

life's a journey not a destination

Ngăn người dùng chọn ngày cuối tuần dùng jQuery UI DatePicker

Leave a comment


jQuery UI DatePicker xây dựng sẵn hàm “noWeekends”, ngăn người dùng chọn các ngày cuối tuần bằng cách vô hiệu hóa chúng.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>jQuery DatePicker with noWeekends function</title>
    <link rel="Stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#datepic").datepicker({ beforeShowDay: $.datepicker.noWeekends });
        });
    </script>
</head>
<body>
    <input id="datepic" />
</body>
</html>

Như bạn thấy, các ngày cuối tuần đã bị vô hiệu hóa

image

Advertisements

Author: dinhnn

Senior software developer, a technical leader. You can be reached at via email to dinhnguyenngoc@gmail.com, via my blog at dinhnguyenngoc.wordpress.com, and on Twitter @dinhnguyenngoc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s