简体   繁体   English

type = number的用途是什么,即使返回无效值也允许输入0123456789.Ee- +?

[英]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.

相关问题 <input type=“number”>不会阻止无效数字输入,但“element.value”不允许我更正它们 - <input type=“number”> does not prevent the invalid numbers inputting, but “element.value” does not allow me to correct them 输入类型编号以字符串形式返回值 - Input type number is returning the value as string 从输入类型号中获取无效值 - Get invalid value from input type number 使用模式来格式化Number类型输入中的值 - Use a pattern to format value in input of type Number 如何以编程方式在输入type = number中设置无效值? - How to programatically set invalid value in input type=number? 如何允许用户在小数点前输入一定数量的输入值,在小数点后键入一定数量的输入值 - How to allow user to type in certain number of input value before decimal and certain number of input value after decimal 输入类型编号返回null - input type number is returning null 为什么即使数字格式为“1.234.567,89”,ionic ion-input type="number" 也不允许在 iOS 中使用逗号? - Why ionic ion-input type="number" does not allow comma in iOS even if number format is "1.234.567,89"? 输入类型编号只允许 2 个数字 - Allow only 2 numbers on input type number iOS / iPhone类型的“数字”键盘允许冒号 - iOS / iPhone type “number” keyboard to allow colon
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM