1、angularjs写一个大小写转化的input
<div class="form-group">
<label for="page_code" class="control-label">三字母code:{{ code_name }}</label><input class="form-control" style="text-transform:uppercase;"
type="text" id="page_code" ng-model="code_name" ng-change="checkTextThree()">
</div>
使用双向绑定
$scope.checkTextThree = function () {
$scope.code_name = $scope.code_name.toUpperCase();//转换为大写的字母
//$scope.code_name即为获取 html的名字
// if ($scope.code_name.length > 3) {// alertWarning("只能输入三个字母");
//$scope.code_name = $scope.code_name.substr(0, 3);
// }
};
</script>
2、普通的HTML写的转换大小写的 通过getTElementById获取input
<input type="text" id="fname" οnchange="myFunction()">
function myFunction(){
var x=document.getElementById("fname");
x.value=x.value.toUpperCase();
}
</script>