-
1. Re: how to mask a credit card input field
kamal_khadka Sep 27, 2013 12:24 PM (in response to kamal_khadka)1 of 1 people found this helpfulI have resolved the issue with the following:
I created two field one output and input.
Output displays the customer old credit card last four digit.
Input field is where customer can choose to put new one if they like to.
ccValidator checks if the credit card is valid or not.
<s:decorate id="oldCardDecoration" template="/layout/edit.xhtml">
<ui:define name="label">
<h:outputText value="Old #{messages.editBillingProfile_cardNumber}" />
</ui:define>
<h:outputText
value="XXXXXXX-#{dashboardMediator.currentCustomerCreditCardNumber}">
</h:outputText>
</s:decorate>
<s:decorate id="cardNumberDecoration" template="/layout/edit.xhtml">
<ui:define name="label">
<h:outputText value="New #{messages.editBillingProfile_cardNumber}" />
</ui:define>
<h:inputText id="ccNumber" onclick="this.value=''"
value="#{dashboardMediator.currentCustomerCreditCard.card}" validator="ccValidator">
<a4j:support event="onblur" bypassUpdates="true" ajaxSingle="true" reRender="cardNumberDecoration" />
</h:inputText>
</s:decorate>
--------------------------------------------------------------------------------------
private String card = "";
public void setCard(String cardNumber){
if(cardNumber.length() != 0)
setCardNumber(cardNumber);
else
setCardNumber(getCardNumber());
}
@Transient
public String getCard()
{
return card;
}