I need to have some masks in my input fields in my form.
I try to insert the jQuery.js
and jQuery.MaskedInput.js
as show in the code below:
<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>
BUt nothing so far.
UPDATE
With BalusC $("[id='form:phone']").mask("(99) 9999-9999");
it works fine! (thanks dude).
But I need apply this mask in a datatable :
<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>
Any idea ?