简体   繁体   中英

p:inputMask - how to customize the mask characters e.g. force input to capitalize certain letter

I would like to force input to capitalize a letter in certain position of text using p:inputMask. In jquery-plugins.js one can find following definition: a: "[A-Za-z]" . My goal is to get something like: a: "[az]", A: "[AZ]" . Is it possible to get this without big and maybe harmful changes in PrimeFaces source code?

If the existing definitions (a, 9,*) are not sufficient, you can add your own ones. You can change it to anything you like by using regular expressions by putting this in your page:

$.mask.definitions['*']= "[\\S]"

This eg meaning any non-whitespace character, so #, % etc are allowed to;

$.mask.definitions['A']= "[A-Z]"
$.mask.definitions['a']= "[a-z]"

Make 'a' require lowercase and 'A' uppercase

See also

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM