Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

javascript - 强制表单文本为小写(Forcing form text to be lower-case)

How could I force the text in the "username" text input to be lower-case regardless of what user types?(不管什么用户类型,如何强制“用户名”文本input中的文本小写?)

<div class="register">
   <label for="username">Select username:</label>
</div> 
<div class="registerform">
    <input name="username" class="registerfont" type="text"
           id="username" maxlength="15" style="height:35px; width:300px">
</div>
  ask by John translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

in CSS:(在CSS中:)

form input[type="text"] {
    text-transform: lowercase;
}

otherwise in JS:(否则在JS中:)

var text="this is my text.";
var lowercase=text.toLowerCase();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...