标签:lan jquer type com 划线 result ace ack body
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>js判断字符串是否有下划线</title> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> </head> <body> <!-- <input type="text" onclick="chk();"> --> <script> var str="SH_20181030_3_25001"; var a=str.length; var str1 = str.replace(/\_+/g,"") var b=str1.length; var c=a-b; if(c!==3){ //alert(‘名字下划线有问题‘); }else{ //alert("ok"); } var a = /^\w{2}_\d{8}_\d{1,2}_\d{5}$/; // alert(a.test(str)); var aa="1"; var b = /^\d{1,2}$/; //alert(b.test(aa)); // // function chk() { // var patrn = /^\d+(\.\d+)?$/; // var result = true; // $("input[type=text]").each(function () { // if (!patrn.exec(this.value)) { // alert("请输入正确的数字!"); // result = false; // } // }) // return result; // } </script> </body> </html>
标签:lan jquer type com 划线 result ace ack body
原文地址:https://www.cnblogs.com/quitpoison/p/10795474.html