Geen omschrijving

register.js 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. // JavaScript Document
  2. /**复选框**/
  3. $('.agreeNotice').click(function(){
  4. var formbox = $(this).closest("form");
  5. if(formbox.find('.gree').prop('checked')){
  6. formbox.find('.agreeNotice em').css('background-position','0px 0px');
  7. formbox.find('.gree').prop('checked',false);
  8. formbox.find('.agreeNotice').next('span').show();
  9. }else{
  10. formbox.find('.gree').prop('checked',true);
  11. formbox.find('.agreeNotice').next('span').hide();
  12. formbox.find('.agreeNotice em').css('background-position','0px -12px');
  13. }
  14. });
  15. //手机、邮箱切换
  16. $(".phone").click(function(){
  17. $(this).find("img").attr("src","images/phoneIcon2.png");
  18. $(".mail").find("img").attr("src","images/mailIcon.png");
  19. $(".mail").removeClass("active");
  20. $(this).addClass("active");
  21. $(".styleline").animate({left:"0px"});
  22. $("#mail_form").hide();
  23. $('#phone_form').show();
  24. });
  25. $(".mail").click(function(){
  26. $(this).find("img").attr("src","images/mailIcon2.png");
  27. $(".phone").find("img").attr("src","images/phoneIcon.png");
  28. $(".phone").removeClass("active");
  29. $(this).addClass("active");
  30. $(".styleline").animate({left:"151px"});
  31. $("#phone_form").hide();
  32. $("#mail_form").show();
  33. });
  34. //手机注册模块
  35. //验证手机号
  36. var phonePass = false;
  37. function phoneVal(){
  38. var phone= $("#lp_phone").val();
  39. if(phone.length==0){
  40. $(".msgphone1").text("请输入您的手机号码");
  41. }else{
  42. var hunPhone=/^1[3|4|5|7|8]\d{9}$/;
  43. if(hunPhone.test(phone.trim())){
  44. $(".msgphone1").text("");
  45. phonePass = true;
  46. }else{
  47. phonePass = false;
  48. $(".msgphone1").text("手机格式正确,请输入正确的手机号码");
  49. }
  50. }
  51. }
  52. $("#lp_phone").blur(function(){
  53. phoneVal();
  54. });
  55. //验证随机验证码
  56. var phoneCode=false;
  57. $("#lp_yzm").blur(function(){
  58. var authCode=$("#lp_yzm").val();
  59. if(authCode.length==0){
  60. $(".msgphone2").text("请输入您的验证码");
  61. phoneCode=false;
  62. }else{
  63. var d=/^[0-9a-zA-Z]{4}$/;
  64. if(d.test(authCode.trim())){
  65. $(".msgphone2").text("");
  66. phoneCode=true;
  67. }
  68. else{
  69. $(".msgphone2").text("请输入您的验证码不正确");
  70. phoneCode=false;
  71. }
  72. }
  73. });
  74. //获取手机验证码
  75. var setTime;
  76. $(".getcode1").click(function(){
  77. $(".coderli span").removeClass("getcode1").addClass("getcode2");;
  78. setTime=setInterval(Countdown,1000);
  79. phoneVerificationCode();
  80. })
  81. var j=60;
  82. function Countdown(){
  83. j--;
  84. $(".getcode2").text(j);
  85. if(j==0){
  86. $(".coderli span").removeClass("getcode2").addClass("getcode1").text("请重新获取验证码");
  87. clearInterval(setTime);
  88. j=60;
  89. }
  90. }
  91. var state;
  92. function phoneVerificationCode(){
  93. if(phonePass){
  94. $.ajax("/ajax/regmobilephone",
  95. {
  96. type: "get",
  97. async: true,
  98. success: function(data) {
  99. if(data.success) {
  100. state=data.data;
  101. }
  102. },
  103. error: function() {
  104. $.MsgBox.Alert('message', 'fail')
  105. },
  106. data: {
  107. "mobilePhone": $("#lp_phone").val()
  108. },
  109. dataType: 'json'
  110. });
  111. }
  112. };
  113. //验证手机验证码
  114. var setpass1= false;
  115. function setPhoneCode(){
  116. var pass= $("#lp_coder").val();
  117. if(pass.length==0){
  118. $(".msgphone3").text("请输入您的验证码");
  119. }else{
  120. var hunPhone=/^[0-9]{4}$/;
  121. if(hunPhone.test(pass.trim())){
  122. $(".msgphone3").text("");
  123. setpass1 = true;
  124. }else{
  125. $(".msgphone3").text("验证码4位");
  126. }
  127. }
  128. }
  129. $("#lp_coder").blur(function(){
  130. setPhoneCode();
  131. });
  132. //设置密码
  133. var password;
  134. var setpass = false;
  135. function setPassword(){
  136. password= $("#phone_password").val();
  137. if(password.length==0){
  138. $(".msgphone4").text("请输入您的密码");
  139. }else{
  140. var hunPhone=/^[0-9a-zA-Z]{6,}$/;
  141. if(hunPhone.test(password.trim())){
  142. $(".msgphone4").text("");
  143. setpass = true;
  144. }else{
  145. $(".msgphone4").text("密码6到16位");
  146. }
  147. }
  148. }
  149. $("#phone_password").blur(function(){
  150. setPassword();
  151. });
  152. //再次确定密码
  153. var setpassagain = false;
  154. function setPasswordAgain(){
  155. var passwordAgain= $("#phone_password2").val();
  156. if(passwordAgain.length==0){
  157. $(".msgphone5").text("请再次输入您的密码");
  158. }else{
  159. var hunPhone=/^[0-9a-zA-Z]{6,}$/;
  160. if(hunPhone.test(password.trim())&&passwordAgain==password){
  161. $(".msgphone5").text("");
  162. setpassagain= true;
  163. }else{
  164. $(".msgphone5").text("密码错误");
  165. }
  166. }
  167. }
  168. $("#phone_password2").blur(function(){
  169. setPasswordAgain();
  170. });
  171. //手机注册提交
  172. $("#btnn").click(function(){
  173. if(phonePass&&setpass1&&setpassagain)
  174. {
  175. $.ajax("/ajax/regmobile",{
  176. type:"POST",
  177. async: false,
  178. success:function(data){
  179. if(data.success){
  180. loginagain();//调用登录的接口
  181. // $(".completedcover").css("display","block");
  182. // $("#afterSay").click(function(){
  183. // location.href="index.html";
  184. // });
  185. // $("#todayPerfect").click(function(){
  186. // location.href="information-add.html?id="+data.data;
  187. // });
  188. location.href="information-add.html?id="+data.data;
  189. }
  190. },
  191. error:function(){$.MsgBox.Alert('message','fail')},
  192. data:{"state":state,"mobilePhone":$("#lp_phone").val(),
  193. "validateCode":$("#lp_coder").val(),"password":$("#phone_password").val(),
  194. dataType: 'json'}
  195. });
  196. }
  197. });
  198. function loginagain(){
  199. $.ajax("/ajax/login",{
  200. type:"POST",
  201. async: false,
  202. success:function(data){
  203. },
  204. error:function(){$.MsgBox.Alert('message','fail')},
  205. data:{"pw":$("#phone_password").val(),"lk":$("#lp_phone").val()},
  206. dataType: 'json'
  207. });
  208. }
  209. //邮箱注册模块
  210. //邮箱验证
  211. var emailPass = false;
  212. function valEmail()
  213. {
  214. var email = $("#lp_email").val();
  215. var gunf=/^\w+@\w+\.((cn)|(com)|(com\.cn))$/;
  216. if(gunf.test(email.trim())){
  217. $(".msgema1 span").text("");
  218. emailPass = true;
  219. }else{
  220. /*alert("请输入正确是邮箱地址");*/
  221. $(".msgema1 span").text("请输入正确是邮箱地址");
  222. emailPass = false;
  223. }
  224. }
  225. $("#lp_email").blur(function(){
  226. valEmail();
  227. });
  228. //输入密码及确认密码
  229. var oldPass = false;
  230. var isPass = false;
  231. function valOld()
  232. {
  233. var oldPassword = $("#mail_password").val();
  234. if(oldPassword.length==0)
  235. {
  236. $(".msgema2 span").text("请输入密码");
  237. oldPass = false;
  238. }else if(oldPassword.length < 6)
  239. {
  240. $(".msgema2 span").text("密码不少于6位,请输入正确的密码");
  241. }else
  242. {
  243. $(".msgema2 span").text("");
  244. oldPass = true;
  245. }
  246. }
  247. $("#mail_password").blur(function(){
  248. valOld();
  249. })
  250. function valNew()
  251. {
  252. var newPassword = $("#mail_password").val();
  253. var oldPassword = $("#mail_password1").val();
  254. if(oldPassword.length==0)
  255. {
  256. $(".msgema3 span").text("密码不能为空");
  257. }
  258. else if(oldPassword.length<6)
  259. {
  260. $(".msgema3 span").text("密码长度过短,至少六位");
  261. }else if(oldPassword != newPassword)
  262. {
  263. $(".msgema3 span").text("两次密码不一致");
  264. } else
  265. {
  266. isPass = true;
  267. $(".msgema3 span").text("");
  268. }
  269. }
  270. $("#mail_password1").blur(function(){
  271. valNew();
  272. })
  273. //邮箱注册提交
  274. //$("#btnn1").click(function(){
  275. // if(isPass&& emailPass)
  276. // {
  277. // $.ajax("/ajax/reg",{
  278. // type:"POST",
  279. // async: false,
  280. // success:function(data){
  281. // location.href="information-add.html?id="+data.data;
  282. // },
  283. // error:function(){$.MsgBox.Alert('message','fail')},
  284. // data:{"email":$("#lp_email").val(),"password":$("#mail_password1").val()},
  285. // dataType: 'json'}
  286. // );
  287. // }
  288. //});
  289. $("#btnn1").click(function(){
  290. if(isPass&& emailPass)
  291. {
  292. $.ajax("/ajax/regmail",{
  293. type:"GET",
  294. async: false,
  295. success:function(data){
  296. location.href="bind-mail.html";
  297. },
  298. error:function(){$.MsgBox.Alert('message','fail')},
  299. data:{"mail":$("#lp_email").val()},
  300. dataType: 'json'}
  301. );
  302. }
  303. });