Numeric Inputs

Numbers are even easier to validate than text. For number input types, the HTML5 spec gives youattributes like minmax, and step. Each of these do pretty much what you would expect.

min and max set the minimum and maximum values that the arrows in the input will allow. stepsets the increments for between possible values. There’s also value, which sets the starting value of the input.

Of course, you’ll probably notice that users can still type whatever number they want into numeric inputs. If you want to really limit possible values, consider a range instead.

Range Inputs

The range input type creates a slider on the page. It also has minmaxstep and value attributes. If you want to display the current value of the range when it changes, you’ll need to use some JavaScript to pull the value from the range. Here's an example:

  // grab <input id="range-example" type="range" min="0" max="5" step="1"> from the page
var rangeInput = document.querySelector('input#range-example'); // grab <p id="output"></p> to display the output
var output = document.querySelector('p#output'); // update the display when the range changes
rangeInput.onchange = function() {
output.innerHTML = this.value;
};
<input type=number>
<input type=number min=100 max=999 step=5>

Numeric Validation的更多相关文章

  1. MVVM架构~knockoutjs系列之从Knockout.Validation.js源码中学习它的用法

    返回目录 说在前 有时,我们在使用一个插件时,在网上即找不到它的相关API,这时,我们会很抓狂的,与其抓狂,还不如踏下心来,分析一下它的源码,事实上,对于JS这种开发语言来说,它开发的插件的使用方法都 ...

  2. Adding Validation to our Album Forms 添加类属性的一些验证特性

    Adding Validation to our Album Forms We’ll use the following Data Annotation attributes: Required – ...

  3. laravel的validation 中文 文件

    使用方法: 直接替换resources/lang/en/validation.php中的内容 <?php return [ 'unique' => ':attribute 已存在', 'a ...

  4. laravel 验证机制validation

    Laravel 中 validation 验证 返回中文提示 全局设置 自己建一个zn文件夹,然后把en的4个文件全复制过去,修改validation.php的代码为下面的内容,然后在app.php修 ...

  5. spring boot中使用javax.validation以及org.hibernate.validator校验入参

    这里springboot用的版本是:<version>2.1.1.RELEASE</version> 自带了hibernate.validator,所以不用添加额外依赖 1.创 ...

  6. Laravel 中 validation 验证 返回中文提示 全局设置

    <?php return [ /* |-------------------------------------------------------------------------- | V ...

  7. laravel的Validation检索验证错误消息

    基本用法 处理错误消息 错误消息和视图 可用的验证规则 有条件地添加规则 自定义错误消息 自定义验证规则 基本用法 Laravel提供了一个简单.方便的工具,用于验证数据并通过validation类检 ...

  8. jQuery学习之路(8)- 表单验证插件-Validation

    ▓▓▓▓▓▓ 大致介绍 jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求.该插件捆绑了一套有用的验证方法,包括 ...

  9. [转]Excel导入异常Cannot get a text value from a numeric cell解决

    原文地址:http://blog.csdn.net/ysughw/article/details/9288307 POI操作Excel时偶尔会出现Cannot get a text value fro ...

随机推荐

  1. PHP+memcache扩展(集成环境wampserver环境下)

    按照别人的步骤,安装和配置后没有任何的错误提示!在计算机服务里面也看到memcached服务已经开启,但是phpinfo里面就是没有memcache已经安装成功的信息!后来才发现原来是没有开启wamp ...

  2. 深入理解jQuery中$.get、$.post、$.getJSON和$.ajax的用法

    当我们用javascript写ajax程序写得很“开心”的时候,突然有人告诉你有一种东西叫jquery,它会告诉你不直接和HttpRequest是多么的快乐,同时你再也不需要再烦恼纠结的ajax乱码问 ...

  3. jQuery基础之(六)jQuery浏览器的兼容性(以CSS3特写兼容举例)

    CSS3充分吸收多年了web发展的需求,吸收了很多新颖的特性.例如border-radius css3特性中最令人兴奋的莫过于选择器的增强,例如属性选择器可以根据某个属性值来选择标记,位置选择器可以根 ...

  4. javascript 漏洞

    1.javascript语言中,每一个对象都有一个对应的原型对象,称为prototype对象.  继承是基于原型的! 2.prototype对象的作用,就是定义所有实例对象共享的属性和方法! 3.“原 ...

  5. NODE学习:利用nodeJS去抓网页的信息

    1:引用模块"http" (执行命令node app.js "http://www.baidu.com") //app.jsvar http = require ...

  6. yii2系统定义的常用路径别名

    @yii 表示Yii框架所在的目录,也是 yii\BaseYii 类文件所在的位置: @app 表示正在运行的应用的根目录,一般是 digpage.com/frontend :物理路径 @vendor ...

  7. Android中实现自定义的拍照应用

    可以参考:http://www.android-doc.com/guide/topics/media/camera.html 一.添加相应的权限 <uses-permission android ...

  8. HDU 2896 病毒侵袭

    Problem Description 当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻....在这样的时刻,人们却异常兴奋——我们能在有生之年看到500年一遇的世界奇观,那是多么幸福 ...

  9. MyEclipse使用SVN进行项目版本控制

    一.搭建SVN服务器. 例如,使用VisualSVN Server,下载后安装. (1)在Repositories(版本库)上右击,新建Repository,选择Regular FSFS reposi ...

  10. Lua函数之二

    Lua函数之二 Lua中函数的两个重要特性: 1.函数和其他类型(如number.string)一样,可以存放在变量中,也可以存放在table中,可以作为函数的参数,还可以作为函数的返回值. 2.嵌套 ...