Change Input to Upper Case

前端 未结 15 823
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 22:02

JS:



        
15条回答
  •  被撕碎了的回忆
    2020-12-07 22:30

    I couldn't find the text-uppercase in Bootstrap referred to in one of the answers. No matter, I created it;

    .text-uppercase {
      text-transform: uppercase;
    }
    

    This displays text in uppercase, but the underlying data is not transformed in this way. So in jquery I have;

    $(".text-uppercase").keyup(function () {
        this.value = this.value.toLocaleUpperCase();
    });
    

    This will change the underlying data wherever you use the text-uppercase class.

提交回复
热议问题