Capitalize

Asked

Viewed 133 times

1

I have an input and I would like that when the user type the letters will be uppercase by the effect of javascript. Without the form I can, more when I put the form does not work.

`

<ui:define name="content">  
<h:form id="frm">
    <p:outputLabel value="Cliente" for="cliente" />
    <p:inputText id="cliente" value="#{cadastroOrcamentoBean.orcamento.cliente}" />

</h:form>
</ui:define>`

`

$("#cliente").keyup(function(){
var start = this.selectionStart,
    end = this.selectionEnd;

$(this).val( $(this).val().toUpperCase() );
this.setSelectionRange(start, end);});

`

  • Because the css does not have the effect that javascript does of the letter being uppercase.

  • It’s calling javascript, because when I shoot <h:form id="frm">.. </h:form> it works

  • I believe the problem is how to put the ids here $("#client")

1 answer

1

I managed to solve it. The selector was as in the code below.

$("#frm\\:cliente").keyup(function(){

var start = this.selectionStart,
    end = this.selectionEnd;

$(this).val( $(this).val().toUpperCase() );
this.setSelectionRange(start, end);});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.