Text-mask: Upper case

Created on 10 Jan 2017  路  6Comments  路  Source: text-mask/text-mask

I'd like to only allow upper case letters, so using [A-Z], obviously lower case letters are now simply discarded. Is there a way I could simply convert lower case letters to upper case on the fly?

Most helpful comment

Just in case it might help someone, with angular2 I just have the following function in my component:

public toUpperCase(conformedValue: string): string {
  return conformedValue.toUpperCase();
}

And in my template I have the this:

<input id="bic" type="text"formControlName="bic" [textMask]="{mask: bicMask, pipe: toUpperCase}" />

All 6 comments

It's possible to use a pipe that upper-cases all entries. The code for the pipe could be something like:

function upperCasePipe(conformedValue) {
  return conformedValue.toUpperCase()
}

Thanks for your question!

How do you then use the pipe?

It depends on the framework component that you're using. You can start by reading the README.md of the framework component that you're using which will then lead you to this documentation page, which contains information about using pipe.

Got it working thanks :)

Awesome!

Just in case it might help someone, with angular2 I just have the following function in my component:

public toUpperCase(conformedValue: string): string {
  return conformedValue.toUpperCase();
}

And in my template I have the this:

<input id="bic" type="text"formControlName="bic" [textMask]="{mask: bicMask, pipe: toUpperCase}" />
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ktriek picture ktriek  路  3Comments

gabrielamarques picture gabrielamarques  路  6Comments

refo picture refo  路  6Comments

danvc picture danvc  路  5Comments

douglasdtc picture douglasdtc  路  3Comments