当前位置:网站首页>input number 纯数字输入 限制长度 限制 最大值
input number 纯数字输入 限制长度 限制 最大值
2022-07-17 13:28:00 【清木青沐】
使用js的oninput即可简单实现,不需要些复杂的代码
// 限制最大值10
<input type="number" oninput="if(value>10)value=10" />
// 限制最小值0
<input type="number" oninput="if(value<0)value=0" />
// 限制输入长度,适用于字符串
<input type="number" oninput="if(value.length>40)value=value.slice(0,40)" />
//长度7 最大值40 最小值0
<input type="number" oninput="if(value>40)value=40;if(value.length>7)value=value.slice(0,7);if(value<0)value=0" />边栏推荐
- Know what it is, and know why, JS object creation and inheritance
- 空天地海一体化网络体系架构与网络切片技术
- Map遍历 key-value 的4种方法
- Pytorch与权重衰减(L2范数)
- "Baidu side" angrily sprayed the interviewer! Isn't it that the tree time increases by a line number?
- 二分类学习推广到多分类学习
- NAT技术及NAT ALG
- Structure the combat battalion | module 7
- 如何在双链笔记软件中建立仪表盘和知识库?以嵌入式小组件库 NotionPet 为例
- mysql不能启动了?相关组件缺失?系统升级?组件不匹配?开始重装mysql
猜你喜欢

Pytoch framework learning record 1 cifar-10 classification

机器学习模型的评估方法

军品研制过程所需文件-进阶版

JSP based novel writing and creation website

LeetCode 2249. Count the number of grid points in the circle

如何在双链笔记软件中建立仪表盘和知识库?以嵌入式小组件库 NotionPet 为例

多元线性回归详解

37. Flex layout

常见集合特性

Know what it is, and know why, JS object creation and inheritance
随机推荐
Leetcode丑数题解
NAT技术及NAT ALG
How to build dashboard and knowledge base in double chain note taking software? Take the embedded widget library notionpet as an example
OpenCV编程:OpenCV3.X训练自己的分类器
过拟合与欠拟合
[Acwing] 第 60 场周赛 C-AcWing 4496. 吃水果
C serialport configuration and attribute understanding
Beego framework realizes file upload + seven cattle cloud storage
Modify the default path of jupyter see this article!
双向NAT技术
Pytoch framework learning record 1 cifar-10 classification
自动化之图形界面库pyautogui
"Baidu side" angrily sprayed the interviewer! Isn't it that the tree time increases by a line number?
SAP AppGyver 的 Universal Theme System 使用介绍
LeetCode 2315. 统计星号(字符串)
论文笔记:Mind the Gap An Experimental Evaluation of Imputation ofMissing Values Techniques in TimeSeries
数据库面基知识汇总后
常见集合特性
Stream stream
华为防火墙(NGFW)的双机热备