当前位置:网站首页>Regular verification
Regular verification
2022-04-22 06:43:00 【Bring in the red moon】
1. Verify positive and negative decimals ( monitor input Events and retain several decimal places )
if(value){
// Whether regular verification is positive or negative With or without a decimal point
let reg = /^(-){1}$|[1-9]+(.\d+)?$|^-?0(\d+)?$|^-?[1-9]+[.0-9]*(.\d+)?$/;
if (!reg.test(e.target.value)) {
console.log(" Please enter a number ")
}
// With . Intercepting string The length exceeds 2 Determined not to be a number Such as 1.2.3 It doesn't count
if (value.split('.').length>2) {
console.log(" Please enter a number ")
}
// Judge how many decimal places to keep
if (value.split('.')[0].length>2) {
console.log(" Keep two decimal places ")
}
}
版权声明
本文为[Bring in the red moon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220556230964.html
边栏推荐
- Digital beauty technology won the "top ten intelligent risk control management innovation award" of the banker
- The installation of redis is started and used by rookies (Windows)
- Redis取出数据乱码问题
- grpc长连接keepalive
- Iframe子父级传参
- Redis fetches out data with garbled code
- 创新实训(二)任务划分
- 小程序自定义原生底部导航
- 在微信小程序中打开的页面不能超过10个,达到10个页面后,就不能再打开新的页面
- 一套sql语句同时支持Oracle跟Mysql?
猜你喜欢
随机推荐
Pgbackrest practice
Pixel系列无痛升级
Mvcc transaction isolation in PostgreSQL
uniapp全局拦截401跳转到登录页
Liang Kun, CTO of Shumei technology, suggested: technology + operation combination to prevent and control "pig killing plate"
Functions and differences between synchronized keyword and volatile keyword
Excel工作表忘记密码后取消密码
js判断数据类型最全的5种方法
Scenario of PostgreSQL online adjusting the maximum number of connections
关于调试指纹时候遇到的其他问题
利用win自带功能让处于同一局域网的两个电脑之间互传文件(速度和本地磁盘间互传相同)
Pgdoucer best practices: Series 3
Shumei technology was invited to participate in the content governance label seminar of ICT Institute
Flink理论基础
The installation of redis is started and used by rookies (Windows)
创新实训(十一)机票爬取 公司信息
ArcGIS 纵断面分析
Solutions for minors protection in the social industry of digital beauty technology: guarding the "social circle" of minors
The legal red line of minors that cannot be ignored in America
如何设置窗口函数中窗口的大小









