$("#showTooltips").click(function() { alert("準備提交註冊……"); var tel=document.getElementById("telephone").value; var pas=document.getElementById("password").value; console.log(tel+";"+pas); if(isPas(pas)){ alert("不能全是數字,不能全是字母,不能全是符號(這裏只列出了部分符號,可自己增加,有的符號可能需要轉義),長度不能少於8位"); } else { if (isMobile1(tel)) { $.ajax({ type: "post", url: "registerUser", async: false, contentType: "application/x-www-form-urlencoded", data: { "user": $('#user').val(), "password": $('#password').val(), "telephone": $('#telephone').val() }, success: function (data) { if (data == "註冊成功") { alert("註冊成功"); window.location.href = "/login"; } else { alert(data); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("請求在連接過程中出現錯誤..\n" + errorThrown); } }); } else{ alert("手機號有錯誤"); } } }); function isMobile1(str) { if (/^[0-9]{11}$/.test(str)) { return true; } else { return false; } } function isPas(str) { if (/(?!^\\d+$)(?!^[a-zA-Z]+$)(?!^[_#@]+$).{8,}$/.test(str)) { return false; } else { return true; } }
註冊約束手機號,和密碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.