【发布时间】:2011-12-14 13:24:04
【问题描述】:
我需要在表单的输入字段中添加一些掩码。
我尝试插入jQuery.js 和jQuery.MaskedInput.js,如下面的代码所示:
<h:head>
<h:outputScript name="jquery-1.6.4.min.js" library="javascript" />
<h:outputScript name="jquery.maskedinput-1.3.js" library="javascript" />
<script>
jQuery(function($){
$("#date").mask("99/99/9999");
$("#phone").mask("(999) 999-9999");
$("#tin").mask("99-9999999");
$("#ssn").mask("999-99-9999");
});
</script>
<title>TITLE</title>
</h:head>
<h:body>
<h:form id="form">
<h:inputText id= "date" />
</h:form>
</h:body>
目前还没有。
更新
使用 BalusC $("[id='form:phone']").mask("(99) 9999-9999"); 可以正常工作! (多谢,伙计)。
但我需要在数据表中应用这个掩码:
<script>
jQuery(function($){
$("input.phones").mask("(999) 999-9999");
});
</script>
<title>TITLE</title>
<h:form id="form">
<h:panelGrid columns="3">
<h:outputLabel for="phones" value="Telefone(s) :" />
<h:dataTable id="phones" value="#{profile.user.userPhones}" var="item">
<h:column>
<h:inputText id= "phone" value="#{item.phone}" />
</h:column>
<h:column>
<h:commandButton value="Remove" action="#{profile.removePhone}"/>
</h:column>
<h:column>
<rich:message id="m_phone" for="phone" />
</h:column>
</h:dataTable>
<h:commandButton value="Add" action="#{profile.addPhone}"/>
</h:panelGrid>
</h:form>
有什么想法吗?
【问题讨论】:
标签: jquery jsf jsf-2 richfaces input-mask