根据输入字段值禁用primefaces日历中的多个日期

时间:2014-05-12 13:21:30

标签: primefaces

    

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
            <script>
                 jQuery(document).ready(function() {
//                      $('#datepicker').datepicker({changeMonth : true, 
//         changeYear : true, 
//         dateFormat: 'yy-mm-dd',
//         minDate: 0, 
//         beforeShowDay: function(date) { 
//                                var day = date.getDay();
//                                return [(day != 0), ''];
//                        }
//      });  
 var datelist = jQuery.parseJSON('#{bean.res}');   
                        $("#datepicker").datepicker({
                            changeMonth : true, 
                            changeYear : true, 
                            dateFormat: 'yy-mm-dd',
                            beforeShowDay: function(d) { 
                                var dmy = "";
                                dmy += ("00" + d.getDate()).slice(-2) + "-";
                                dmy += ("00" + (d.getMonth() + 1)).slice(-2) + "-";
                                dmy += d.getFullYear();
                                 var day = d.getDay();
                                if ($.inArray(dmy, datelist) >= 0) {
                                    // Hide Given Dates IN Array
                                      // For Sunday (day !== 0) (or) false
                                    return [false, ""];
                                }
                                else {
                                    // For Sunday (day !== 0) (or) true
                                    return [(day !== 0), ""];
                                }
                            }
                        }); 
                 });   
   $(function() {

$( "#datepicker1" ).datepicker({
        changeMonth:true,
        changeYear:true

                        }); 
                 });   
function tuesdaysAndFridaysDisabled(date)
{
  var day = date.getDay();

  return [(day != 2 &amp;&amp; day != 5), '']
}
  </script>
 </h:head>
 <h:body>
<p:layout fullPage="true">

                <p:layoutUnit position="north" size="100" resizable="true" closable="true" collapsible="true">
                    Header
                </p:layoutUnit>

                <p:layoutUnit position="south" size="100" closable="true" collapsible="true">
                    Footer
                </p:layoutUnit>

                <p:layoutUnit position="west" size="175" header="Left" collapsible="true">
                    <p:menu>
                        <p:submenu label="Resources">
                            <p:menuitem value="Demo" url="http://www.primefaces.org/showcase-labs/ui/home.jsf" />
                            <p:menuitem value="Documentation" url="http://www.primefaces.org/documentation.html" />
                            <p:menuitem value="Forum" url="http://forum.primefaces.org/" />
                            <p:menuitem value="Themes" url="http://www.primefaces.org/themes.html" />

                        </p:submenu>

                    </p:menu>
                </p:layoutUnit>

                <p:layoutUnit position="center">

                        <p:inputText   id="datepicker"/>      
                        <p:inputText   id="datepicker1"/>  
  <p:calendar value="#{dateBean.date}" beforeShowDay="tuesdaysAndFridaysDisabled" />
                </p:layoutUnit>

            </p:layout>

        </h:body>

    </f:view>
</html>

在上面我发布了xhtml页面,但我被认为是处理这个问题,因为日历输入字段基于另一个输入字段,例如employee_id字段意味着基于employee_id字段值应该出现日历值。

0 个答案:

没有答案