zoukankan      html  css  js  c++  java
  • 前端输入框判断集合input

    输入框判断

    手机号只能是11位并且全部都是数字

    			phoneRule(e) {  //电话格式
    				let val = e.detail.value.split('');
    				let reg = /^[0-9]*$/ ; //判断是否是数字
                                    let strNumbr = ''; //结果
    				if (val[0] != 1) { //必须是1开头的
    					setTimeout(() => {
    						this.addData.mobile = '';
    					}, 10)
    				} else {
    					if (val) {
    						val.forEach((item, index) => {
    							if (reg.test(item)) {
    								strNumbr = strNumbr + item;
    							}
    						});
    						setTimeout(() => {
    							if(strNumbr.length>11){ //最多11位数
    								strNumbr = strNumbr.slice(0,11);
    							}
    							this.addData.mobile = strNumbr;
    						}, 10)
    					}
    				}
    			}
    
    有问题联系QQ1291481728或在下方评论,会在第一时刻处理。
  • 相关阅读:
    Linux 命令
    g++/gcc
    emacs lisp
    vim 快捷键
    emacs快捷键
    Valgrind 例子
    Valgrind
    gprof
    cppcheck
    gdb常用命令
  • 原文地址:https://www.cnblogs.com/ooo51o/p/15735252.html
Copyright © 2011-2022 走看看