1.正則表示式常識語法規則1.常規建立正則: var reg = new RegExp(“正則表示式”,“匹配模式”)預設正則:"/內容/" 屬性為object==>檢查字串中是否含有"內容"測試方法:test() 返回一個boolean“匹配模式”i :(ignore) 忽略大小寫g :全域性匹配模式字面量建立正則var reg = /正則表示式/匹配模式2.本專案完成正則一覽
實現reg正則檢測
(1)判斷輸入內容是否包含指定的內容B(忽略大小寫)//獲取物件 var input1 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input1"); var submit1 = document.querySelector("#wrap > .form-inline > .form-group > #submit1"); var input1Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input1-show"); //1.判斷輸入內容是否包含指定的內容B(忽略大小寫) var reg1 = /b/i; submit1.onclick = function() { if(reg1.test(input1.value)) { reg1.test(input1.value); input1Show.innerHTML = "√"; input1Show.style.color = "green"; input1Show.style.fontSize = "20px"; console.log("輸入: ", input1.value); } else { input1Show.innerHTML = "x"; input1Show.style.color = "red"; input1Show.style.fontSize = "20px"; input1.value = ""; input1.placeholder = "輸入錯誤,請包含B"; } }
reg
(2)判斷輸入內容是否包含指定的內容A或B(忽略大小寫)var input2 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input2"); var submit2 = document.querySelector("#wrap > .form-inline > .form-group > #submit2"); var input2Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input2-show"); //2.判斷輸入內容是否包含指定的內容A或B(忽略大小寫) var reg2 = /a|b/i; submit2.onclick = function() { if(reg2.test(input2.value)) { reg2.test(input2.value); input2Show.innerHTML = "√"; input2Show.style.color = "green"; input2Show.style.fontSize = "20px"; } else { input2Show.innerHTML = "x"; input2Show.style.color = "red"; input2Show.style.fontSize = "20px"; input2.value = ""; input2.placeholder = "輸入錯誤,請包含A或B"; } }
reg
(3)判斷字母範圍 [a-y],除[a-y]之外錯誤var input3 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input3"); var submit3 = document.querySelector("#wrap > .form-inline > .form-group > #submit3"); var input3Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input3-show"); //3.判斷字母範圍 [a-y],除[a-y]之外錯誤 var reg3 = /^[a-y]$/g; submit3.onclick = function() { if(reg3.test(input3.value)) { reg3.test(input3.value); input3Show.innerHTML = "√"; input3Show.style.color = "green"; input3Show.style.fontSize = "20px"; } else { input3Show.innerHTML = "x"; input3Show.style.color = "red"; input3Show.style.fontSize = "20px"; input3.value = ""; input3.placeholder = "輸入錯誤,字母範圍 在[a-y]"; } }
reg
(4)判斷字母(任意字母)範圍 [A-z],包括下劃線var input4 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input4"); var submit4 = document.querySelector("#wrap > .form-inline > .form-group > #submit4"); var input4Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input4-show"); //4.判斷字母(任意字母)範圍 [A-z],包括下劃線 var reg4 = /^[A-z]{1,}$/g; submit4.onclick = function() { console.log(input4.value); if(reg4.test(input4.value)) { //判斷之後,返回false,需要再次更新reg reg4.test(input4.value); input4Show.innerHTML = "√"; input4Show.style.color = "green"; input4Show.style.fontSize = "20px"; } else { input4Show.innerHTML = "x"; input4Show.style.color = "red"; input4Show.style.fontSize = "20px"; input4.value = ""; input4.placeholder = "(任意字母)範圍 [A-z],包括下劃線"; } }
reg
(5)判斷字串中: 都含有a開頭,c結尾 a[…]c -> abcevnthcvar input5 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input5"); var submit5 = document.querySelector("#wrap > .form-inline > .form-group > #submit5"); var input5Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input5-show"); //5.判斷字串中: 都含有a開頭,c結尾 a[...]c -> abcevnthc var reg5 = /^a[A-z]{1,}c$/i; submit5.onclick = function() { if(reg5.test(input5.value)) { //判斷之後,返回false,需要再次更新reg reg5.test(input5.value); input5Show.innerHTML = "√"; input5Show.style.color = "green"; input5Show.style.fontSize = "20px"; } else { input5Show.innerHTML = "x"; input5Show.style.color = "red"; input5Show.style.fontSize = "20px"; input5.value = ""; input5.placeholder = "(任意字母)範圍 [A-z],都含有a開頭,c結尾"; } }
reg
(6)判斷除了[a[DNF]{1,}c$]以外的值=truevar input6 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input6"); var submit6 = document.querySelector("#wrap > .form-inline > .form-group > #submit6"); var input6Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input6-show"); //6.判斷除了[^a[^DNF]{1,}c$]以外的值=true var reg6 = /^a[^NDF]{1,}c$/i; submit6.onclick = function() { if(reg6.test(input6.value)) { //判斷之後,返回false,需要再次更新reg reg6.test(input6.value); input6Show.innerHTML = "√"; input6Show.style.color = "green"; input6Show.style.fontSize = "20px"; } else { input6Show.innerHTML = "x"; input6Show.style.color = "red"; input6Show.style.fontSize = "20px"; input6.value = ""; input6.placeholder = "不包含DNF的字元"; } }
reg
(7)判斷0-9任意陣列[0-9],包含[0-9]即可,且以0-9結尾var input7 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input7"); var submit7 = document.querySelector("#wrap > .form-inline > .form-group > #submit7"); var input7Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input7-show"); //7.判斷0-9任意陣列[0-9],包含[0-9]即可,且以0-9結尾 var reg7 = /[0-9]{1,}$/; submit7.onclick = function() { if(reg7.test(input7.value)) { //判斷之後,返回false,需要再次更新reg reg7.test(input7.value); input7Show.innerHTML = "√"; input7Show.style.color = "green"; input7Show.style.fontSize = "20px"; } else { input7Show.innerHTML = "x"; input7Show.style.color = "red"; input7Show.style.fontSize = "20px"; input7.value = ""; input7.placeholder = "包含[0-9]即可,且以0-9結尾"; } }
reg
(8)判斷單個字元 連續出現3次的c /bbb/ 或者 /b{3}/ 這裡引用量詞{3},量詞…{}只對前面的第一個[字元集合]起作用var input8 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input8"); var submit8 = document.querySelector("#wrap > .form-inline > .form-group > #submit8"); var input8Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input8-show"); //8.判斷單個字元 連續出現3次的c /bbb/ 或者 /b{3}/ 這裡引用量詞{3},量詞...{}只對前面的第一個[字元集合]起作用 var reg8 = /c{3}/; submit8.onclick = function() { if(reg8.test(input8.value)) { //判斷之後,返回false,需要再次更新reg reg8.test(input8.value); input8Show.innerHTML = "√"; input8Show.style.color = "green"; input8Show.style.fontSize = "20px"; } else { input8Show.innerHTML = "x"; input8Show.style.color = "red"; input8Show.style.fontSize = "20px"; input8.value = ""; input8.placeholder = "必須帶3個c"; } }
reg
(9)判斷多個字元 連續出現3次 /(cevent){3}/ivar input9 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input9"); var submit9 = document.querySelector("#wrap > .form-inline > .form-group > #submit9"); var input9Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input9-show"); //9.判斷多個字元 連續出現3次 /(cevent){3}/i var reg9 = /(cevent){3}/i; submit9.onclick = function() { if(reg9.test(input9.value)) { //判斷之後,返回false,需要再次更新reg reg9.test(input9.value); input9Show.innerHTML = "√"; input9Show.style.color = "green"; input9Show.style.fontSize = "20px"; } else { input9Show.innerHTML = "x"; input9Show.style.color = "red"; input9Show.style.fontSize = "20px"; input9.value = ""; input9.placeholder = "必須出現cevent這個字串"; } }
reg
(10)判斷中間值 a連續出現3次ce b結尾,兩邊不要求 /a(ce){3}b/ivar input10 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input10"); var submit10 = document.querySelector("#wrap > .form-inline > .form-group > #submit10"); var input10Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input10-show"); //10.判斷中間值 a連續出現3次ce b結尾,兩邊不要求 /a(ce){3}b/i var reg10 = /a(ce){3}b/i; submit10.onclick = function() { if(reg10.test(input10.value)) { //判斷之後,返回false,需要再次更新reg reg10.test(input10.value); input10Show.innerHTML = "√"; input10Show.style.color = "green"; input10Show.style.fontSize = "20px"; } else { input10Show.innerHTML = "x"; input10Show.style.color = "red"; input10Show.style.fontSize = "20px"; input10.value = ""; input10.placeholder = "a連續出現3次ce b結尾,兩邊不要求"; } }
reg
(11)判斷中間值 連續出現1到3次,不可超過3次 /a(ce){1,3}b/ {min,max}出現次數var input11 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input11"); var submit11 = document.querySelector("#wrap > .form-inline > .form-group > #submit11"); var input11Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input11-show"); //11.判斷中間值 連續出現1到3次,不可超過3次 /a(ce){1,3}b/ {min,max}出現次數 var reg11 = /a(ce){1,3}b/i; submit11.onclick = function() { if(reg11.test(input11.value)) { //判斷之後,返回false,需要再次更新reg reg11.test(input11.value); input11Show.innerHTML = "√"; input11Show.style.color = "green"; input11Show.style.fontSize = "20px"; } else { input11Show.innerHTML = "x"; input11Show.style.color = "red"; input11Show.style.fontSize = "20px"; input11.value = ""; input11.placeholder = "連續出現1到3次(ce)"; } }
reg
(12)判斷中間值 最小連續出現1次以上(ce){1,} 也可以(ce)+ 符號+代表最小1var input12 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input12"); var submit12 = document.querySelector("#wrap > .form-inline > .form-group > #submit12"); var input12Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input12-show"); //12.判斷中間值 最小連續出現1次以上(ce){1,} 也可以(ce)+ 符號+代表最小1 var reg12 = /a(ce){1,}b/i; submit12.onclick = function() { if(reg12.test(input12.value)) { //判斷之後,返回false,需要再次更新reg reg12.test(input12.value); input12Show.innerHTML = "√"; input12Show.style.color = "green"; input12Show.style.fontSize = "20px"; } else { input12Show.innerHTML = "x"; input12Show.style.color = "red"; input12Show.style.fontSize = "20px"; input12.value = ""; input12.placeholder = "至少出現出現1次(ce)"; } }
reg
(13)判斷中間值 /a(ce)c/ 有沒有都行={0,} 如果有值,必須等於=cevar input13 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input13"); var submit13 = document.querySelector("#wrap > .form-inline > .form-group > #submit13"); var input13Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input13-show"); //13.判斷中間值 /a(ce)*c/ 有沒有都行*={0,} 如果有值,必須等於=ce var reg13 = /a(ce)*b/i; submit13.onclick = function() { if(reg13.test(input13.value)) { //判斷之後,返回false,需要再次更新reg reg13.test(input13.value); input13Show.innerHTML = "√"; input13Show.style.color = "green"; input13Show.style.fontSize = "20px"; } else { input13Show.innerHTML = "x"; input13Show.style.color = "red"; input13Show.style.fontSize = "20px"; input13.value = ""; input13.placeholder = "ab*c中間值可有可無"; } }
reg
(14)判斷中間值 ?= 0個/1個 其他都為false /ac?b/var input14 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input14"); var submit14 = document.querySelector("#wrap > .form-inline > .form-group > #submit14"); var input14Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input14-show"); //14.判斷中間值 ?= 0個/1個 其他都為false /ac?b/ var reg14 = /ac?b/i; submit14.onclick = function() { if(reg14.test(input14.value)) { //判斷之後,返回false,需要再次更新reg reg14.test(input14.value); input14Show.innerHTML = "√"; input14Show.style.color = "green"; input14Show.style.fontSize = "20px"; } else { input14Show.innerHTML = "x"; input14Show.style.color = "red"; input14Show.style.fontSize = "20px"; input14.value = ""; input14.placeholder = "ac*b中間值1個/0個c"; } }
reg
(15)檢查是否以a開頭 ^ 區分於 [^…] 除了…都為truevar input15 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input15"); var submit15 = document.querySelector("#wrap > .form-inline > .form-group > #submit15"); var input15Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input15-show"); //15.檢查是否以a開頭 ^ 區分於 [^...] 除了...都為true var reg15 = /^a/i; submit15.onclick = function() { if(reg15.test(input15.value)) { //判斷之後,返回false,需要再次更新reg reg15.test(input15.value); input15Show.innerHTML = "√"; input15Show.style.color = "green"; input15Show.style.fontSize = "20px"; } else { input15Show.innerHTML = "x"; input15Show.style.color = "red"; input15Show.style.fontSize = "20px"; input15.value = ""; input15.placeholder = "以a開頭"; } }
reg
(16)檢查是否以a結尾 $ /a$/ivar input16 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input16"); var submit16 = document.querySelector("#wrap > .form-inline > .form-group > #submit16"); var input16Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input16-show"); //16.檢查是否以a結尾 $ /a$/i var reg16 = /a$/i; submit16.onclick = function() { if(reg16.test(input16.value)) { //判斷之後,返回false,需要再次更新reg reg16.test(input16.value); input16Show.innerHTML = "√"; input16Show.style.color = "green"; input16Show.style.fontSize = "20px"; } else { input16Show.innerHTML = "x"; input16Show.style.color = "red"; input16Show.style.fontSize = "20px"; input16.value = ""; input16.placeholder = "以a結尾"; } }
reg
(17)以a開頭,以a結尾,中間任意字母數字 “a” /a/ /^a[A-z]{1,}a$/var input17 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input17"); var submit17 = document.querySelector("#wrap > .form-inline > .form-group > #submit17"); var input17Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input17-show"); //17.以a開頭,以a結尾,中間任意字母數字 "a" /a/ /^a[A-z]{1,}a$/ var reg17 = /^a[A-z0-9]{1,}a$/i; submit17.onclick = function() { if(reg17.test(input17.value)) { //判斷之後,返回false,需要再次更新reg reg17.test(input17.value); input17Show.innerHTML = "√"; input17Show.style.color = "green"; input17Show.style.fontSize = "20px"; } else { input17Show.innerHTML = "x"; input17Show.style.color = "red"; input17Show.style.fontSize = "20px"; input17.value = ""; input17.placeholder = "以a開頭,以a結尾,中間任意字母數字"; } }
reg
(18)檢查字串是否為手機號:/^1[3-9][0-9]{9}$/var input18 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input18"); var submit18 = document.querySelector("#wrap > .form-inline > .form-group > #submit18"); var input18Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input18-show"); /* 18.** 檢查字串是否為手機號:/^1[3-9][0-9]{9}$/ 省略{1}一個 這裡引用量詞{3},量詞...{}只對前面的第一個[字元集合]起作用 * 規則:11位 * 第1位:以1開頭 ^1 * 第2位:3-9任意數字 [3-9] * 第3位-第11位(9個):任意數字 [0-9]{9}$ */ var reg18 = /^1{1}[3-9][0-9]{9}$/; submit18.onclick = function() { if(reg18.test(input18.value)) { //判斷之後,返回false,需要再次更新reg reg18.test(input18.value); input18Show.innerHTML = "√"; input18Show.style.color = "green"; input18Show.style.fontSize = "20px"; } else { input18Show.innerHTML = "x"; input18Show.style.color = "red"; input18Show.style.fontSize = "20px"; input18.value = ""; input18.placeholder = "請輸入11位手機號"; } }
reg
(19)19.檢查字串中是否有. * 任意字元:. 點 * 使用跳脫字元:\ * 判斷\ 使用\\ * 字串中2個斜槓代表1個斜槓\ * 如果為建構函式=new RegExp("a","i") 正則\一個斜槓,"\\"字串中2個,正則\\斜槓,字串中\\\\4個12345
var input19 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input19"); var submit19 = document.querySelector("#wrap > .form-inline > .form-group > #submit19"); var input19Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input19-show"); /* 19.檢查字串中是否有. * 任意字元:. 點 * 使用跳脫字元:\ * 判斷\ 使用\\ * 字串中2個斜槓代表1個斜槓\ * 如果為建構函式=new RegExp("a","i") 正則\一個斜槓,"\\"字串中2個,正則\\斜槓,字串中\\\\4個 */ var reg19 = /\./; //判斷字串中有.且有\ ,中間一個值[a-z] var reg191 = /\.[a-z]\\/; submit19.onclick = function() { if(reg19.test(input19.value)) { //判斷之後,返回false,需要再次更新reg reg19.test(input19.value); input19Show.innerHTML = "√"; input19Show.style.color = "green"; input19Show.style.fontSize = "20px"; } else { input19Show.innerHTML = "x"; input19Show.style.color = "red"; input19Show.style.fontSize = "20px"; input19.value = ""; input19.placeholder = "請輸入包含點."; } }
reg
(20)元字元 * \b :單詞邊界,[word]單詞前後不允許有其他字母、單詞 * \B :除了單詞邊界 * \d :任意數字 [0-9] * \D :除了任意數字[^0-9] * \w :任意字母和數字,_下劃線 [A-z0-9_] * \W :除了字母和數字,_下劃線 [^A-z0-9_] \s :空格 * \S :除了空格12345678
var input20 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input20"); var submit20 = document.querySelector("#wrap > .form-inline > .form-group > #submit20"); var input20Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input20-show"); /* 元字元 * \b :單詞邊界,[word]單詞前後不允許有其他字母、單詞 * \B :除了單詞邊界 * \d :任意數字 [0-9] * \D :除了任意數字[^0-9] * \w :任意字母和數字,_下劃線 [A-z0-9_] * \W :除了字母和數字,_下劃線 [^A-z0-9_] \s :空格 * \S :除了空格 */ //匹配任意字母 數字 可以有空格 [0-9] 可以用\d替換 ,至少有3個 /^[a-zA-Z0-9\s]{0,}$/ var reg20 = /^[a-zA-Z\d\s]{3,}$/; //檢查任意字母或數字,包括下劃線 var reg201 = /^\w{0,}$/i; //匹配任意字母 數字 _ 可以有空格 var reg202 = /^[\w\s]{0,}$/i; //單詞邊界:檢查字串中是否有child,/child/包含child,如果有children,則=true,不對,需要單詞邊界 var reg203 = /\bchild\b/; submit20.onclick = function() { if(reg20.test(input20.value)) { //判斷之後,返回false,需要再次更新reg reg20.test(input20.value); input20Show.innerHTML = "√"; input20Show.style.color = "green"; input20Show.style.fontSize = "20px"; } else { input20Show.innerHTML = "x"; input20Show.style.color = "red"; input20Show.style.fontSize = "20px"; input20.value = ""; input20.placeholder = "匹配任意字母 數字 可以有空格 至少有3個"; } }
reg
(21)使用者名稱輸入:去除空格【改-】var input21 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input21"); var submit21 = document.querySelector("#wrap > .form-inline > .form-group > #submit21"); var input21Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input21-show"); var blank21 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .blank21"); //21.使用者名稱輸入:去除空格【改-】 //判斷字母、數字、空格,最小1位 var reg21 = /^[a-zA-Z0-9\s]{1,}$/; //str30 = str29.replace(/^\s*/, ""); //console.log("去除字首空格:", str30); //str31 = str30.replace(/\s*$/, ""); //console.log("去除字尾空格:", str31); //去除前、中間、後 空格【這個去除是每個字母進行檢查,如果是-的替換=h-e-l-l-o】 替換不可用 //str32 = str31.replace(/[\s]{0,}/g, ""); //console.log("去除 中間 空格:", str32); //21.使用者名稱輸入:去除 前、後空格 重點:+ 一個或多個,* 0個或多個 //var regBlank=/^\s*|\s{0,}$/g; //var strBlank=" hello children hah "; //var regResult=strBlank.replace(regBlank,""); //console.log("去除前、後 綴空格:",regResult); submit21.onclick = function() { if(reg21.test(input21.value)) { reg21.test(input21.value); input21Show.innerHTML = "√"; input21Show.style.color = "green"; input21Show.style.fontSize = "20px"; //1.去除前後空格 var removeFBBlank=/^\s*|\s{0,}$/g; var rFBB=input21.value.replace(removeFBBlank,""); console.log("rFBB: ",rFBB); //2.去除中間空格,這裡也可以替換+為{1,} var removeMBlank=/\s+/g; blank21.value=rFBB.replace(removeMBlank,"-"); } else { input21Show.innerHTML = "x"; input21Show.style.color = "red"; input21Show.style.fontSize = "20px"; input21.value = ""; input21.placeholder = "只能輸入數字、字母、空格"; } }
reg
(22)22.電子郵箱:cevent .163 @ ccc .com .cn * 第一組:任意字母數字 [a-zA-Z0-9]{3,10} * |- 字母+數字+下劃線 =\w{3,10} 長度[最短3-10] * 第二組:.任意字母數字下劃線 (\.\w) 整體可有可無 * |- (\.\w){0,10} * 第三組:@ * |- @ * 第四組:任意字母數字 [a-zA-Z0-9] 長度[1-11] * |- [a-zA-Z0-9]{1,11} * 第五組:.任意字母 [a-zA-Z] 長度[最短2][最長5] * |- [\.a-zA-Z]{2,5} * 第六組:.任意字母 [a-zA-Z] 長度[最短2][最長5]與上一個相同,更新上一個正則 * |- (\.[a-zA-Z]{2,5}){1,2} * 注意:整個開頭結尾約束: ^()$12345678910111213
var input22 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > #input22"); var submit22 = document.querySelector("#wrap > .form-inline > .form-group > #submit22"); var input22Show = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .input22-show"); var blank22 = document.querySelector("#wrap > .form-inline > .form-group > .input-group > .blank22"); var reg22 = /^[a-zA-Z0-9]{3,10}(\.\w{0,10})@[a-zA-Z0-9]{1,11}(\.[a-zA-Z]{2,5}){1,2}$/; submit22.onclick = function() { if(reg22.test(input22.value)) { reg22.test(input22.value); input22Show.innerHTML = "√"; input22Show.style.color = "green"; input22Show.style.fontSize = "20px"; } else { input22Show.innerHTML = "x"; input22Show.style.color = "red"; input22Show.style.fontSize = "20px"; input22.value = ""; input22.placeholder = "郵箱:[email protected]"; } }
reg
最新評論