Wednesday, 21 May 2014

Convert input text Content to Upper Case or Lower Case

In this post i am going to talk about converting lower case data to upper case (or Upper Case data to Lower Case). There are multiple solutions to achieve this but i am showing there different methods.

1. you can use contentStyle="text-transform:uppercase;" on input text field.
2. Using java script code

<af:resource type="javascript">
      function convertToUpperCase(evt){
        var field = evt.getCurrentTarget();
        var fieldVal= field .getSubmittedValue();
        field .setValue(fieldVal.toUpperCase());        

 <af:inputText label="Label 1" id="it1">
                <af:clientListener method="convertToUpperCase" type="valueChange"/>

3. You can create class with accessors and use toUpperCase() of String class

    public void setFirstName(String value) {
        setAttributeInternal(FIRSTNAME, value.toUpperCase());

Thanks :) Happy Learning :) 

No comments:

Post a Comment