PageRenderTime 95ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/install2/validate.js

https://github.com/MyITCRM/myitcrm1
JavaScript | 248 lines | 205 code | 37 blank | 6 comment | 99 complexity | d481aabeb993b231841ed4b84da0a53d MD5 | raw file
  1. <script type="text/javascript">
  2. //<![CDATA[
  3. function data_copy()
  4. {
  5. if(document.install.copy[0].checked){
  6. document.install.COMPANY_ADDRESS.value=document.install.address.value;
  7. document.install.COMPANY_CITY.value=document.install.city.value;
  8. document.install.COMPANY_STATE.value=document.install.state.value;
  9. document.install.COMPANY_ZIP.value=document.install.zip.value;
  10. }else{
  11. document.install.COMPANY_ADDRESS.value="";
  12. document.install.COMPANY_CITY.value="";
  13. document.install.COMPANY_STATE.value="";
  14. document.install.COMPANY_ZIP.value="";
  15. }
  16. }
  17. function validate_install(frm) {
  18. var value = '';
  19. var errFlag = new Array();
  20. var _qfGroups = {};
  21. _qfMsg = '';
  22. // Check DB settings
  23. value = frm.elements['db_user'].value;
  24. if (value == '' && !errFlag['db_user']) {
  25. errFlag['db_user'] = true;
  26. _qfMsg = _qfMsg + '\n - Missing The Root Database User Name!';
  27. frm.elements['db_user'].className = 'error';
  28. }
  29. value = frm.elements['db_password'].value;
  30. if (value == '' && !errFlag['db_password']) {
  31. errFlag['db_password'] = true;
  32. _qfMsg = _qfMsg + '\n - Missing The Root Database User Password!';
  33. frm.elements['db_password'].className = 'error';
  34. }
  35. value = frm.elements['db_host'].value;
  36. if (value == '' && !errFlag['db_host']) {
  37. errFlag['db_host'] = true;
  38. _qfMsg = _qfMsg + '\n - Missing The Database Name!';
  39. frm.elements['db_host'].className = 'error';
  40. }
  41. // Check The Default Admin settings
  42. value = frm.elements['default_password'].value;
  43. if (value != '' && value.length < 6 && !errFlag['default_password']) {
  44. errFlag['default_password'] = true;
  45. _qfMsg = _qfMsg + '\n - Admins Password must be at least 6 characters';
  46. frm.elements['default_password'].className = 'error';
  47. }
  48. value = frm.elements['default_password'].value;
  49. if (value != '' && value.length > 50 && !errFlag['default_password']) {
  50. errFlag['default_password'] = true;
  51. _qfMsg = _qfMsg + '\n - Admins Password cannot be more than 12 characters';
  52. frm.elements['default_password'].className = 'error';
  53. }
  54. value = frm.elements['default_password'].value;
  55. var regex = /^[a-zA-Z0-9]+$/;
  56. if (value != '' && !regex.test(value) && !errFlag['default_password']) {
  57. errFlag['default_password'] = true;
  58. _qfMsg = _qfMsg + '\n - Admins Password can only contain letters and numbers';
  59. frm.elements['password'].className = 'error';
  60. }
  61. value = frm.elements['first_name'].value;
  62. if (value == '' && !errFlag['first_name']) {
  63. errFlag['first_name'] = true;
  64. _qfMsg = _qfMsg + '\n - Please enter the Admins First Name';
  65. frm.elements['first_name'].className = 'error';
  66. }
  67. value = frm.elements['last_name'].value;
  68. if (value == '' && !errFlag['last_name']) {
  69. errFlag['last_name'] = true;
  70. _qfMsg = _qfMsg + '\n - Please enter the Admins Last Name';
  71. frm.elements['last_name'].className = 'error';
  72. }
  73. value = frm.elements['display_name'].value;
  74. if (value == '' && !errFlag['display_name']) {
  75. errFlag['display_name'] = true;
  76. _qfMsg = _qfMsg + '\n - Please enter the Admins Display Name';
  77. frm.elements['display_name'].className = 'error';
  78. }
  79. value = frm.elements['address'].value;
  80. if (value == '' && !errFlag['address']) {
  81. errFlag['address'] = true;
  82. _qfMsg = _qfMsg + '\n - Please enter the Admins Address';
  83. frm.elements['address'].className = 'error';
  84. }
  85. value = frm.elements['address'].value;
  86. if (value != '' && value.length > 50 && !errFlag['address']) {
  87. errFlag['address'] = true;
  88. _qfMsg = _qfMsg + '\n - Address cannot be more than 50 characters';
  89. frm.elements['address'].className = 'error';
  90. }
  91. value = frm.elements['city'].value;
  92. if (value == '' && !errFlag['city']) {
  93. errFlag['city'] = true;
  94. _qfMsg = _qfMsg + '\n - Please enter the Employees city';
  95. frm.elements['city'].className = 'error';
  96. }
  97. value = frm.elements['city'].value;
  98. if (value != '' && value.length > 50 && !errFlag['city']) {
  99. errFlag['city'] = true;
  100. _qfMsg = _qfMsg + '\n - City cannot be more than 50 characters';
  101. frm.elements['city'].className = 'error';
  102. }
  103. value = frm.elements['state'].value;
  104. if (value == '' && !errFlag['state']) {
  105. errFlag['state'] = true;
  106. _qfMsg = _qfMsg + '\n - Please enter the Admins state';
  107. frm.elements['state'].className = 'error';
  108. }
  109. value = frm.elements['state'].value;
  110. if (value != '' && value.length > 20 && !errFlag['state']) {
  111. errFlag['state'] = true;
  112. _qfMsg = _qfMsg + '\n - State cannot be more than 20 characters';
  113. frm.elements['state'].className = 'error';
  114. }
  115. value = frm.elements['zip'].value;
  116. if (value == '' && !errFlag['zip']) {
  117. errFlag['zip'] = true;
  118. _qfMsg = _qfMsg + '\n - Please enter the Admins zip';
  119. frm.elements['zip'].className = 'error';
  120. }
  121. value = frm.elements['zip'].value;
  122. if (value != '' && value.length > 10 && !errFlag['zip']) {
  123. errFlag['zip'] = true;
  124. _qfMsg = _qfMsg + '\n - Zip cannot be more than 10 characters';
  125. frm.elements['zip'].className = 'error';
  126. }
  127. value = frm.elements['home_phone'].value;
  128. if (value == '' && !errFlag['home_phone']) {
  129. errFlag['home_phone'] = true;
  130. _qfMsg = _qfMsg + '\n - Please enter the Admins Home Phone';
  131. frm.elements['home_phone'].className = 'error';
  132. }
  133. value = frm.elements['default_email'].value;
  134. if (value == '' && !errFlag['default_email']) {
  135. errFlag['default_email'] = true;
  136. _qfMsg = _qfMsg + '\n - Please enter the Admins email address';
  137. frm.elements['default_email'].className = 'error';
  138. }
  139. value = frm.elements['default_email'].value;
  140. var regex = /^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/;
  141. if (value != '' && !regex.test(value) && !errFlag['email']) {
  142. errFlag['email'] = true;
  143. _qfMsg = _qfMsg + '\n - Please enter a valid email address';
  144. frm.elements['email'].className = 'error';
  145. }
  146. value = frm.elements['default_email'].value;
  147. if (value != '' && value.length > 50 && !errFlag['email']) {
  148. errFlag['email'] = true;
  149. _qfMsg = _qfMsg + '\n - Email cannot be more than 50 characters';
  150. frm.elements['email'].className = 'error';
  151. }
  152. // Company Settings
  153. value = frm.elements['COMPANY_NAME'].value;
  154. if (value == '' && !errFlag['COMPANY_NAME']) {
  155. errFlag['COMPANY_NAME'] = true;
  156. _qfMsg = _qfMsg + '\n - Please Your Company Name';
  157. frm.elements['COMPANY_NAME'].className = 'error';
  158. }
  159. value = frm.elements['COMPANY_ADDRESS'].value;
  160. if (value == '' && !errFlag['COMPANY_ADDRESS']) {
  161. errFlag['homePhone'] = true;
  162. _qfMsg = _qfMsg + '\n - Please enter Your Company Address';
  163. frm.elements['COMPANY_ADDRESS'].className = 'error';
  164. }
  165. value = frm.elements['COMPANY_CITY'].value;
  166. if (value == '' && !errFlag['COMPANY_CITY']) {
  167. errFlag['COMPANY_CITY'] = true;
  168. _qfMsg = _qfMsg + '\n - Please enter Your Company City';
  169. frm.elements['COMPANY_CITY'].className = 'error';
  170. }
  171. value = frm.elements['COMPANY_STATE'].value;
  172. if (value == '' && !errFlag['COMPANY_STATE']) {
  173. errFlag['COMPANY_STATE'] = true;
  174. _qfMsg = _qfMsg + '\n - Please enter Your Company State';
  175. frm.elements['COMPANY_STATE'].className = 'error';
  176. }
  177. value = frm.elements['COMPANY_ZIP'].value;
  178. if (value == '' && !errFlag['COMPANY_ZIP']) {
  179. errFlag['COMPANY_ZIP'] = true;
  180. _qfMsg = _qfMsg + '\n - Please enter Your Company Zip ';
  181. frm.elements['COMPANY_ZIP'].className = 'error';
  182. }
  183. value = frm.elements['COMPANY_PHONE'].value;
  184. if (value == '' && !errFlag['COMPANY_PHONE']) {
  185. errFlag['COMPANY_PHONE'] = true;
  186. _qfMsg = _qfMsg + '\n - Please enter Your Company Phone ';
  187. frm.elements['COMPANY_PHONE'].className = 'error';
  188. }
  189. // File PAth Settings
  190. value = frm.elements['default_path'].value;
  191. if (value == '' && !errFlag['default_path']) {
  192. errFlag['default_path'] = true;
  193. _qfMsg = _qfMsg + '\n - Please enter The File Path ';
  194. frm.elements['default_path'].className = 'error';
  195. }
  196. value = frm.elements['default_site_name'].value;
  197. if (value == '' && !errFlag['default_site_name']) {
  198. errFlag['default_site_name'] = true;
  199. _qfMsg = _qfMsg + '\n - Please enter the web site URL ';
  200. frm.elements['default_site_name'].className = 'error';
  201. }
  202. if (_qfMsg != '') {
  203. _qfMsg = 'Invalid information entered.' + _qfMsg;
  204. _qfMsg = _qfMsg + '\nPlease correct these fields.';
  205. alert(_qfMsg);
  206. return false;
  207. }
  208. return true;
  209. }
  210. //]]>
  211. </script>