如何使用javascript仅大写输入字段中句子的第一个字母?
当我键入内容时,我希望在javascript的输入字段中只将句子的第一个字母大写 这是我的网站,我想在那里使用它 有什么解决办法吗 以下是我的HTML代码:如何使用javascript仅大写输入字段中句子的第一个字母?,javascript,html,Javascript,Html,当我键入内容时,我希望在javascript的输入字段中只将句子的第一个字母大写 这是我的网站,我想在那里使用它 有什么解决办法吗 以下是我的HTML代码: <div class="form-group"> <label for="name" class="label-head">Company Name <sup><span class="glyphicon glyphicon-
<div class="form-group">
<label for="name" class="label-head">Company Name <sup><span
class="glyphicon glyphicon-asterisk red" aria-hidden="true"></span></sup></label>
<input type="text" class="form-control text-box-length input-lg" id="companyname" placeholder="Enter Your Company Name" data-validation="required" maxlength="50">
</div>
公司名称
调用此功能,并在每次按键时设置要输入的文本
function titleCase(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
这不是重复的,因为我只希望第一个字母大写,而不是每个单词。。