HTML数字输入删除小数点? [英] HTML Number Input removes decimal point?

查看:121
本文介绍了HTML数字输入删除小数点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单上输入数字时遇到问题。当我输入一个数字,如88.2并提交时,没有问题。但是当这个人做同样的事时,你可以在php代码中看到如果你从数字输入中回显变量,它已经删除了小数点()。

当他使用逗号时,它不会删除他的小数点,但是当我使用逗号时,它会将其删除。有没有什么办法可以解决这个问题,让它只接受。作为小数点?



以下是输入:

 < input id =versionname =versionstep =0.1min =1.0max =250.0type =numberclass =input-smallplaceholder =87.2>< / input> 

PHP代码中没有任何异常,只有

  echo $ _POST ['version']; 

input-small css

  .input-small {
width:90px;


解决方案

type ='number'step ='any'可以解决问题。



http://dev.w3.org/html5/markup/input.number.html


I have a problem with the number input on a form. When I enter a number, say 88.2 and submit it, there are no problems. But when this other person does the same, you can see in the php code if you echo the variable from the number input, that it has removed the decimal point (.).

It does not remove his decimal point when he uses a comma however, when I use a comma it removes that for me. Is there any way to fix this and make it only accept "." as decimal point?

Here's the input:

<input id="version" name="version" step="0.1" min="1.0" max="250.0" type="number" class="input-small" placeholder="87.2"></input>

There is nothing in the PHP code that's unusual, only

echo $_POST['version'];

input-small css:

.input-small {
  width: 90px;
}

解决方案

type='number' step='any' may solve the issue.

http://dev.w3.org/html5/markup/input.number.html

这篇关于HTML数字输入删除小数点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆