我在Foundation 6中有一个表单字段但它不允许十进制输入。
HTML
<input type="number" name="decimal_amount" max="10" placeholder="" required>
当我输入 8.5 时,我收到此错误:
请输入有效值。两个最接近的值是8和9.
以下是整个HTML块:
<head>
<!-- Foundation CSS via CDN -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/foundation/6.1.2/foundation.min.css">
<!-- 1140px Grid styles for IE -->
<!--[if lte IE 9]><link rel="stylesheet" href="css/ie.css" type="text/css" media="screen" /><![endif]-->
<!-- The 1140px Grid - http://cssgrid.net/ -->
<link rel="stylesheet" href="../css/1140.css" type="text/css" media="screen" />
<!--css3-mediaqueries-js - http://code.google.com/p/css3-mediaqueries-js/ - Enables media queries in some unsupported browsers-->
<script type="text/javascript" src="../js/css3-mediaqueries.js"></script>
<!-- Foundation JavaScript via CDN -->
<script src="https://cdn.jsdelivr.net/foundation/6.1.2/foundation.min.js"></script>
</head>
<div class="large-6 columns">
<label class="left">Ranking (scale 1-10, decimals allowed)
<input type="number" name="decimal_amount" max="10" placeholder="" required>
</label>
</div>
<script src="js/vendor/jquery.min.js"></script>
<script src="js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
答案 0 :(得分:3)
这真的是HTML5的问题。将step="0.1"
添加到输入以描述小数精度的类型。这是第100个例子。
<input type="number" name="decimal_amount" max="10" step="0.01" placeholder="" required>
http://www.w3.org/TR/2012/WD-html5-20121025/common-input-element-attributes.html#attr-input-step