fcode.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. var Validate = function(){
  2. this.required = function(id)
  3. {
  4. var inputVal=$(id).val();
  5. if(inputVal=="")
  6. {
  7. return false;
  8. }
  9. else {
  10. return true;
  11. }
  12. };
  13. this.mobile = function (id)
  14. {
  15. var inputVal=$(id).val();
  16. var tel=new RegExp("^[1][3-8]+\\d{9}");
  17. if(tel.test(inputVal))
  18. {
  19. return true;
  20. }
  21. else
  22. {
  23. return false;
  24. }
  25. }
  26. };
  27. var CountDown = function(time)
  28. {
  29. if(isNaN(time))
  30. {
  31. return;
  32. }
  33. this.time = time;
  34. this.countDown = function(){
  35. if(this.isStart())
  36. {
  37. return false;
  38. }
  39. else
  40. {
  41. var that=this;
  42. var target=event.target;
  43. var time = parseInt(that.time);
  44. var a = setInterval(function()
  45. {
  46. time = time - 1;
  47. target.innerHTML = time;
  48. if(time <= 0)
  49. {
  50. clearInterval(a);
  51. target.innerHTML = '重新发送';
  52. }
  53. },1000);
  54. }
  55. };
  56. this.isStart = function()
  57. {
  58. var target = event.target;
  59. if(target.innerHTML == '重新发送' || target.innerHTML == '获取验证码')
  60. {
  61. return false;
  62. }
  63. else
  64. {
  65. return true;
  66. }
  67. }
  68. };
  69. var ajaxServer = function(type,url,data,callback)
  70. {
  71. $.ajax({
  72. type:type,
  73. dataType:'json',
  74. url:url,
  75. data:data,
  76. success:callback
  77. });
  78. };
  79. var app=function()
  80. {
  81. var app=navigator.userAgent.toLowerCase(),//判断设备
  82. app_nav=navigator.appVersion.toLowerCase(),
  83. href='';
  84. if (app_nav.indexOf('iphone')>-1&&app.indexOf('iphone')){
  85. href='http://a.app.qq.com/o/simple.jsp?pkgname=com.lrlz.beautyshop';
  86. } else if (app.indexOf('micromessenger')>-1 && app_nav.indexOf('android')>-1) {
  87. href = "http://p.lrlz.com/hfive/android_down/index.html";
  88. }
  89. else {
  90. href="javascript:void(0)";
  91. }
  92. return href;
  93. };