怎么把注册时候的手机弄为必填项(说具体点呀)

2016-07-07 16:27 来源:www.chinab4c.com 作者:ecshop专家

http://www.bsvl.cn/user.php?act=register
如题


回答:
  1. /* *
  2. * 处理注册用户
  3. */
  4. function register()
  5. {
  6. var frm = document.forms['formUser'];
  7. var username = Utils.trim(frm.elements['username'].value);
  8. var email = frm.elements['email'].value;
  9. var password = Utils.trim(frm.elements['password'].value);
  10. var confirm_password = Utils.trim(frm.elements['confirm_password'].value);
  11. var checked_agreement = frm.elements['agreement'].checked;
  12. var msn = frm.elements['other[msn]'] ? Utils.trim(frm.elements['other[msn]'].value) : '';
  13. var qq = frm.elements['other[qq]'] ? Utils.trim(frm.elements['other[qq]'].value) : '';
  14. var home_phone = frm.elements['other[home_phone]'] ? Utils.trim(frm.elements['other[home_phone]'].value) : '';
  15. var office_phone = frm.elements['other[office_phone]'] ? Utils.trim(frm.elements['other[office_phone]'].value) : '';
  16. var mobile_phone = frm.elements['other[mobile_phone]'] ? Utils.trim(frm.elements['other[mobile_phone]'].value) : '';


  17. var msg = "";
  18. // 检查输入
  19. var msg = '';
  20. if (username.length == 0)
  21. {
  22. msg += username_empty + '\n';
  23. }
  24. else if (username.match(/^\s*$|^c:\\con\\con$|[%,\'\*\"\s\t\<\>\&\\]/))
  25. {
  26. msg += username_invalid + '\n';
  27. }
  28. else if (username.length < 3)
  29. {
  30. //msg += username_shorter + '\n';
  31. }

  32. if (email.length == 0)
  33. {
  34. msg += email_empty + '\n';
  35. }
  36. else
  37. {
  38. if ( ! (Utils.isEmail(email)))
  39. {
  40. msg += email_invalid + '\n';
  41. }
  42. }
  43. if (password.length == 0)
  44. {
  45. msg += password_empty + '\n';
  46. }
  47. else if (password.length < 6)
  48. {
  49. msg += password_shorter + '\n';
  50. }
  51. if (confirm_password != password )
  52. {
  53. msg += confirm_password_invalid + '\n';
  54. }
  55. if(checked_agreement != true)
  56. {
  57. msg += agreement + '\n';
  58. }

  59. if (msn.length > 0 && (!Utils.isEmail(msn)))
  60. {
  61. msg += msn_invalid + '\n';
  62. }

  63. if (qq.length > 0 && (!Utils.isNumber(qq)))
  64. {
  65. msg += qq_invalid + '\n';
  66. }

  67. if (office_phone.length>0)
  68. {
  69. var reg = /^[\d|\-|\s]+$/;
  70. if (!reg.test(office_phone))
  71. {
  72. msg += office_phone_invalid + '\n';
  73. }
  74. }
  75. if (home_phone.length>0)
  76. {
  77. var reg = /^[\d|\-|\s]+$/;

  78. if (!reg.test(home_phone))
  79. {
  80. msg += home_phone_invalid + '\n';
  81. }
  82. }
  83. if (mobile_phone.length>0)
  84. {
  85. var reg = /^[\d|\-|\s]+$/;
  86. if (!reg.test(mobile_phone))
  87. {
  88. msg += mobile_phone_invalid + '\n';
  89. }
  90. }
  91. if (msg.length > 0)
  92. {
  93. alert(msg);
  94. return false;
  95. }
  96. else
  97. {
  98. return true;
  99. }
  100. }
复制代码

具体咋子修改哦,

那QQ呢?

我的QQ:86683901谁告诉我哦