[英]what is the use of type = number allow to type 0123456789.Ee-+ even it returning invalid value?
var app = angular.module("myShoppingList", []); app.controller("myCtrl", function($scope) { $scope.addMe=""; });
<html> <head> <link rel="stylesheet" href="style.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.js"></script> </head> <body> <div ng-app="myShoppingList" ng-controller="myCtrl"> <input type="number" ng-model="addMe"> <p>{{addMe}}</p> </body> </html>
Actually input type = number
does not allow most of the special characters to enter. 实际上,输入type = number
不允许大多数特殊字符输入。 But it's only allowing to enter + and - and (Adding and subscription)
even why it does not allowing to enter / and * (divide and multiply)
. 但是,即使它不允许输入/ and * (divide and multiply)
也只允许输入+ and - and (Adding and subscription)
/ and * (divide and multiply)
。
And also the input field value will be invalid while we entering - and +
in the input box 当我们在输入框中输入- and +
,输入字段值也将无效
I am not sure this problem occurred from browser or Html because I got some details from this answer for 0123456789.Ee-+
are all legal characters according to Chrome . 我不确定这个问题是由浏览器还是HTML产生的,因为我从0123456789.Ee-+
答案中得到了一些细节, 根据Chrome,它们都是合法字符 。 But I have checked with this in IE 11 browser as well which is getting this same problem. 但是我已经在IE 11浏览器中对此进行了检查,这也遇到了同样的问题。 So we have an idea about input type = number should allow - and + like 0123456789.Ee-+
value But i don't know what is the use to allow this characters? 因此,我们对输入类型=数字应允许-和+像0123456789.Ee-+
value 这样的想法,但是我不知道允许使用此字符有什么用?
My main question is why the
type=number
allow to enter those character then why it's returning invalid value? 我的主要问题是为什么type=number
允许输入这些字符,然后为什么返回无效值? if the input box returning invalid value then why it's allowing to type those charterers ?? 如果输入框返回无效值,那么为什么允许键入那些租船人? What is the Use? 有什么用? Use ? 使用 ?
I got it for why it is allowing those chars. 我明白为什么允许这些字符。 here is the use of . e + -
这是使用. e + -
. e + -
1e1 = 10// use of e or E
1e+1 = 10// use of +
1e-1 = 0.1// use of -
1.1 = 1.1// use of .
So this is the reason for type=number is allowing to type those characters. 因此,这就是type = number允许键入这些字符的原因。 And if we typing wrongly then only it's will be return
invalid
value. 而且,如果我们键入错误,则只有它会返回invalid
值。
You can check those in below snippet for those values. 您可以在下面的代码段中查看这些值。
var app = angular.module("myShoppingList", []); app.controller("myCtrl", function($scope) { $scope.eorE=1e1; $scope.float=1.1; $scope.plus=1e+1; $scope.mins=1e-1; });
<html> <head> <link rel="stylesheet" href="style.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.js"></script> </head> <body> <div ng-app="myShoppingList" ng-controller="myCtrl"> <input type="number" ng-model="eorE"> <input type="number" ng-model="float"> <input type="number" ng-model="plus"> <input type="number" ng-model="mins"> <p>{{addMe}}</p> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.