denglu.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. function denglu() {
  2. var userCaptcha = $('#userCaptcha').val();
  3. var result= "3333";
  4. // var userName ;
  5. //做一层验证
  6. if (userCaptcha == '') {
  7. document.getElementById("showInfo").style.display = "block";
  8. document.getElementById("showInfo").innerText = "验证码不能为空!";
  9. } else {
  10. if(!checkNumber(userCaptcha)){
  11. document.getElementById("showInfo").style.display = "block";
  12. document.getElementById("showInfo").innerText = "验证码错误!";
  13. return ;
  14. }
  15. // $.ajax({
  16. // type: "post", //post提交方式默认是get
  17. // dataType: "json",
  18. // url: ""+getRealPath()+"/UserMan/login?userNo="+userNo+"&userPass="+userPass+"",
  19. // async: false,
  20. // success: function (data) {
  21. // if(data.result=="1"){
  22. // window.open(getRealPath()+"/View/Index/index.html?userName="+data.userName+"&userNo="+userNo+"", '_self');
  23. // document.cookie="status=success;path=/";//使cookie在整个网站下可用,可以将cookie_dir指定为根目录
  24. // }else {
  25. // $('#showInfo').css('display','block');
  26. // document.getElementById("showInfo").innerText = data.message;
  27. // }
  28. //
  29. // }
  30. // });
  31. }
  32. }
  33. function change() {
  34. $('#kaptchaImage').click(function () {
  35. $(this).attr('src', './login/getCheckNumber?' + Math.floor(Math.random() * 100));
  36. })
  37. }
  38. function checkNumber(userCaptcha){
  39. var flag;
  40. $.ajax({
  41. type: 'post',
  42. url: getRealPath()+'/login/checkNumber/'+userCaptcha,
  43. contenType: 'application/json;charset=utf-8',
  44. dataType:'json',
  45. async: false,//false为异步传输,异步传输才能传全局变量
  46. success:function (data) {
  47. //这里的code属性是自定义的message类,可以用其他方式代替
  48. if(data.code == "200"){
  49. flag = true;
  50. }else if(data.code == "500"){
  51. flag = false;
  52. }
  53. }
  54. });
  55. return flag;
  56. }