/Validate.inc

https://code.google.com/ · PHP · 862 lines · 673 code · 189 blank · 0 comment · 55 complexity · dc2d084f89e33bbd24a0a04fef3c3a6f MD5 · raw file

  1. <%
  2. REM -------------------------------------------------------------------------
  3. REM /ZTITools/Validate.inc
  4. REM -------------------------------------------------------------------------
  5. REM Descricao : Include de validacoes JavaScript
  6. REM Cria?ao : 08:30h 28/12/1998
  7. REM Local : Brasilia/DF
  8. REM Elaborado : Ruben Zevallos Jr. <zevallos@zevallos.com.br>
  9. REM : Eduardo Alves Cortes <edualves@zevallos.com.br>
  10. REM Versao : 1.0.0
  11. REM Copyright : 1998 by Zevallos(r) Tecnologia em Informacao
  12. REM -------------------------------------------------------------------------
  13. REM ALTERACOES
  14. REM -------------------------------------------------------------------------
  15. REM Responsavel : [Nome do executante da alteracao]
  16. REM Data/Hora : [Data e hora da alteracao]
  17. REM Resumo : [Resumo descritivo da alteracao executada]
  18. REM -------------------------------------------------------------------------
  19. Dim sblnPutJSStartEnd
  20. sblnPutJSStartEnd = True
  21. Private Sub JavaScriptBegin
  22. If sblnPutJSStartEnd Then
  23. ShowHTMLCR "<SCRIPT LANGUAGE=""JavaScript"">"
  24. End If
  25. End Sub
  26. Private Sub JavaScriptEnd
  27. If sblnPutJSStartEnd Then
  28. ShowHTMLCR "</SCRIPT>"
  29. End If
  30. End Sub
  31. Private Sub SetPutJSStartEnd(blnAux)
  32. sblnPutJSStartEnd = blnAux
  33. End Sub
  34. REM -------------------------------------------------------------------------
  35. REM Entra FormJavaValidSepDate
  36. REM -------------------------------------------------------------------------
  37. Private Sub FormJavaValidSepDate(ByVal strField, strField2, strField3, strForm, strFunctionName, blnMaiorQueHoje, strMessage)
  38. JavaScriptBegin
  39. ShowHTMLCR "function " & strFunctionName & "(){"
  40. ShowHTMLCR "var dataatual, data, text;"
  41. ShowHTMLCR "if ((document." + strForm + "." & strField & ".value > """") && (document." + strForm + "." & strField2 & ".value > """") && (document." + strForm + "." & strField3 & ".value > """")){"
  42. ShowHTMLCR "text = document." + strForm + "." & strField & ".value + document." + strForm + "." & strField2 & ".value + document." + strForm + "." & strField3 & ".value;"
  43. ShowHTMLCR "if (!isdate(text)){"
  44. ShowHTMLCR "alert(""Data Inv?lida"");"
  45. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  46. ShowHTMLCR "return false;"
  47. ShowHTMLCR "}}"
  48. If blnMaiorQueHoje Then
  49. ShowHTMLCR "dataatual = new Date();"
  50. ShowHTMLCR "data = todate(text);"
  51. ShowHTMLCR "if (data.valueOf() + 90000000 < dataatual.valueOf()) {"
  52. ShowHTMLCR "alert(""" & strMessage & """);"
  53. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  54. ShowHTMLCR "return false;"
  55. ShowHTMLCR "}"
  56. End If
  57. REM If sstrLastValidate > "" Then
  58. REM ShowHTMLCR "return " & sstrLastValidate & "()"
  59. REM End If
  60. ShowHTMLCR "}"
  61. JavaScriptEnd
  62. End Sub
  63. REM -------------------------------------------------------------------------
  64. REM Final da Sub FormJavaValidSepDate
  65. REM -------------------------------------------------------------------------
  66. REM Entra FormJavaValidDate
  67. REM -------------------------------------------------------------------------
  68. Private Sub FormJavaValidDate(ByVal strField, strForm, strFunctionName, blnMaiorQueHoje, strMessage)
  69. JavaScriptBegin
  70. ShowHTMLCR "function " & strFunctionName & "(){"
  71. ShowHTMLCR "var dataatual, data, text;"
  72. ShowHTMLCR "if (document." + strForm + "." & strField & ".value > """"){"
  73. ShowHTMLCR "text = document." + strForm + "." & strField & ".value;"
  74. ShowHTMLCR "if (!isdate(text)){"
  75. ShowHTMLCR "alert(""Data Inv?lida"");"
  76. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  77. ShowHTMLCR "return false;"
  78. ShowHTMLCR "}"
  79. ShowHTMLCR "else"
  80. ShowHTMLCR "{"
  81. ShowHTMLCR "document." + strForm + "." & strField & ".value = datetostring(todate(text))"
  82. ShowHTMLCR "return true}"
  83. ShowHTMLCR "}"
  84. If blnMaiorQueHoje Then
  85. ShowHTMLCR "dataatual = new Date();"
  86. ShowHTMLCR "data = todate(text);"
  87. ShowHTMLCR "if (data.valueOf() + 90000000 < dataatual.valueOf()) {"
  88. ShowHTMLCR "alert(""" & strMessage & """);"
  89. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  90. ShowHTMLCR "return false;"
  91. ShowHTMLCR "}"
  92. ShowHTMLCR "else{return true}"
  93. End If
  94. ShowHTMLCR "}"
  95. JavaScriptEnd
  96. End Sub
  97. REM -------------------------------------------------------------------------
  98. REM Final da Sub FormJavaValidDate
  99. REM -------------------------------------------------------------------------
  100. REM Valida um campo de CGC
  101. REM -------------------------------------------------------------------------
  102. Function FormJavaValidCGC(ByVal strField, strForm, strFunctionName)
  103. JavaScriptBegin
  104. ShowHTMLCR "function " & strFunctionName & "(){"
  105. ShowHTMLCR "var cgc, soma, digito, digito2, multip, i, aux, numero;"
  106. ShowHTMLCR "soma = 0;"
  107. ShowHTMLCR "multip = 5;"
  108. ShowHTMLCR "cgc = document." + strForm + "." & strField & ".value;"
  109. ShowHTMLCR "cgc = leadingzeroes(normalize(cgc), 14);"
  110. ShowHTMLCR "for(i = 0;i <= 11;i++){"
  111. ShowHTMLCR "number = parseInt(cgc.charAt(i));"
  112. ShowHTMLCR "soma += (number * multip);"
  113. ShowHTMLCR "multip+= - 1;"
  114. ShowHTMLCR "if (multip < 2)"
  115. ShowHTMLCR "multip = 9;}"
  116. ShowHTMLCR "aux = soma % 11;"
  117. ShowHTMLCR "if ((aux == 0) || (aux == 1))"
  118. ShowHTMLCR "digito = 0;"
  119. ShowHTMLCR "else"
  120. ShowHTMLCR "digito = 11 - aux;"
  121. ShowHTMLCR "if (parseInt(cgc.charAt(12)) == digito){"
  122. ShowHTMLCR "multip = 6;"
  123. ShowHTMLCR "soma = 0;"
  124. ShowHTMLCR "for(i = 0;i <= 12;i++){"
  125. ShowHTMLCR "numero = parseInt(cgc.charAt(i));"
  126. ShowHTMLCR "soma += (numero * multip);"
  127. ShowHTMLCR "multip+= - 1;"
  128. ShowHTMLCR "if (multip < 2)"
  129. ShowHTMLCR "multip = 9;"
  130. ShowHTMLCR "}"
  131. ShowHTMLCR "aux = soma % 11;"
  132. ShowHTMLCR "if ((aux == 0) || (aux == 1))"
  133. ShowHTMLCR "digito = 0;"
  134. ShowHTMLCR "else"
  135. ShowHTMLCR "digito = 11 - aux;"
  136. ShowHTMLCR "if (parseInt(cgc.charAt(13)) == digito)"
  137. ShowHTMLCR "return true;"
  138. ShowHTMLCR "else{"
  139. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  140. ShowHTMLCR "alert(""Este CGC ? inv?lido"");"
  141. ShowHTMLCR "return false;}}"
  142. ShowHTMLCR "else{"
  143. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  144. ShowHTMLCR "alert(""Este CGC ? inv?lido"");"
  145. ShowHTMLCR "return false;}"
  146. ShowHTMLCR "}"
  147. JavaScriptEnd
  148. End Function
  149. REM ---------------------------------------------------------------------
  150. REM Final da function FormJavaValidCGC
  151. REM -------------------------------------------------------------------------
  152. REM Valida um campo de CPF
  153. REM -------------------------------------------------------------------------
  154. Function FormJavaValidCPF(ByVal strField, strForm, strFunctionName)
  155. JavaScriptBegin
  156. ShowHTMLCR "function " & strFunctionName & "(){"
  157. ShowHTMLCR "var cpf, soma, digito, digito2, multip, i, aux, numero;"
  158. ShowHTMLCR "soma = 0;"
  159. ShowHTMLCR "multip = 10;"
  160. ShowHTMLCR "cpf = document." + strForm + "." & strField & ".value;"
  161. ShowHTMLCR "cpf = leadingzeroes(normalize(cpf), 11);"
  162. ShowHTMLCR "for(i = 0;i <= 8;i++){"
  163. ShowHTMLCR "number = parseInt(cpf.charAt(i));"
  164. ShowHTMLCR "soma += (number * multip);"
  165. ShowHTMLCR "multip+= - 1;}"
  166. ShowHTMLCR "aux = soma % 11;"
  167. ShowHTMLCR "if ((aux == 0) || (aux == 1))"
  168. ShowHTMLCR "digito = 0;"
  169. ShowHTMLCR "else"
  170. ShowHTMLCR "digito = 11 - aux;"
  171. ShowHTMLCR "if (parseInt(cpf.charAt(9)) == digito){"
  172. ShowHTMLCR "multip = 11;"
  173. ShowHTMLCR "soma = 0;"
  174. ShowHTMLCR "for(i = 0;i <= 9;i++){"
  175. ShowHTMLCR "numero = parseInt(cpf.charAt(i));"
  176. ShowHTMLCR "soma += (numero * multip);"
  177. ShowHTMLCR "multip+= - 1;"
  178. ShowHTMLCR "}"
  179. ShowHTMLCR "aux = soma % 11;"
  180. ShowHTMLCR "if ((aux == 0) || (aux == 1))"
  181. ShowHTMLCR "digito = 0;"
  182. ShowHTMLCR "else"
  183. ShowHTMLCR "digito = 11 - aux;"
  184. ShowHTMLCR "if (parseInt(cpf.charAt(10)) == digito)"
  185. ShowHTMLCR "return true;"
  186. ShowHTMLCR "else{"
  187. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  188. ShowHTMLCR "alert(""Este CPF ? inv?lido"");"
  189. ShowHTMLCR "return false;}}"
  190. ShowHTMLCR "else{"
  191. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  192. ShowHTMLCR "alert(""Este CPF ? inv?lido"");"
  193. ShowHTMLCR "return false;}"
  194. ShowHTMLCR "}"
  195. JavaScriptEnd
  196. End Function
  197. REM ---------------------------------------------------------------------
  198. REM Final da function FormJavaValidCPF
  199. REM -------------------------------------------------------------------------
  200. REM Valida um campo de e-mail
  201. REM -------------------------------------------------------------------------
  202. Function FormJavaValidEMail(ByVal strField, strForm, strFunctionName)
  203. JavaScriptBegin
  204. ShowHTMLCR "function " & strFunctionName & "(){"
  205. ShowHTMLCR "var email;"
  206. ShowHTMLCR "email = document." + strForm + "." & strField & ".value;"
  207. ShowHTMLCR "if ((email == """") || ((email.indexOf(""."") != -1) && (email.indexOf(""@"") != -1)))"
  208. ShowHTMLCR "return true;"
  209. ShowHTMLCR "else{"
  210. ShowHTMLCR "document." + strForm + "." & strField & ".focus();"
  211. ShowHTMLCR "alert(""Este e-mail ? inv?lido"");"
  212. ShowHTMLCR "return false;}"
  213. ShowHTMLCR "}"
  214. JavaScriptEnd
  215. End Function
  216. REM ---------------------------------------------------------------------
  217. REM Final da function FormJavaValidEMail
  218. REM -------------------------------------------------------------------------
  219. REM Cria a Classe StrExt
  220. REM -------------------------------------------------------------------------
  221. Private Sub StrExtBegin
  222. JavaScriptBegin
  223. ShowHTMLCR "function mid(text, start, length){return text.substr(start - 1, length);}"
  224. ShowHTMLCR "function left(text, length){return text.substr(0, length);}"
  225. ShowHTMLCR "function midtoend(text, start){return text.substr(start - 1);}"
  226. ShowHTMLCR "function normalize(text)"
  227. ShowHTMLCR "{var i, text2;"
  228. ShowHTMLCR " text2 = text;"
  229. ShowHTMLCR " i = 0;"
  230. ShowHTMLCR " while (i < text2.length)"
  231. ShowHTMLCR " if ((text2.substr(i, 1) < ""0"") || (text2.substr(i, 1) > ""9""))"
  232. ShowHTMLCR " text2 = text2.substr(0, i) + midtoend(text2, i + 2);"
  233. ShowHTMLCR " else"
  234. ShowHTMLCR " i++;"
  235. ShowHTMLCR " return text2;"
  236. ShowHTMLCR "}"
  237. ShowHTMLCR "function leadingzeroes(text, tam){"
  238. ShowHTMLCR " while (text.length < tam)"
  239. ShowHTMLCR " text = ""0"" + text;"
  240. ShowHTMLCR " return text;"
  241. ShowHTMLCR "}"
  242. ShowHTMLCR "function isdate(text){"
  243. ShowHTMLCR "var Dia, Mes, Ano, dataatual;"
  244. ShowHTMLCR " blnis = true;"
  245. ShowHTMLCR " dataatual = new Date();"
  246. ShowHTMLCR " text = normalize(text);"
  247. ShowHTMLCR " Mes = dataatual.getMonth() + 1"
  248. ShowHTMLCR " Ano = dataatual.getFullYear()"
  249. ShowHTMLCR " if (text.length > 1){"
  250. ShowHTMLCR " Dia = parseFloat(left(text, 2));"
  251. ShowHTMLCR " if (text.length > 3){"
  252. ShowHTMLCR " Mes = parseFloat(mid(text, 3,2));"
  253. ShowHTMLCR " }"
  254. ShowHTMLCR " if (text.length > 5){"
  255. ShowHTMLCR " Ano = parseFloat(midtoend(text, 5));}"
  256. ShowHTMLCR " if ((Mes > 12) || (Mes < 1))"
  257. ShowHTMLCR " blnis = false;"
  258. ShowHTMLCR " switch (Mes) {"
  259. ShowHTMLCR " case 1:"
  260. ShowHTMLCR " case 3:"
  261. ShowHTMLCR " case 5:"
  262. ShowHTMLCR " case 7:"
  263. ShowHTMLCR " case 8:"
  264. ShowHTMLCR " case 10:"
  265. ShowHTMLCR " case 12:"
  266. ShowHTMLCR " if ((Dia > 31) || (Dia < 1))"
  267. ShowHTMLCR " blnis = false;break;"
  268. ShowHTMLCR " case 4:"
  269. ShowHTMLCR " case 6:"
  270. ShowHTMLCR " case 9:"
  271. ShowHTMLCR " case 11:"
  272. ShowHTMLCR " if ((Dia > 30) || (Dia < 1))"
  273. ShowHTMLCR " blnis = false;break;"
  274. ShowHTMLCR " case 2:"
  275. ShowHTMLCR " if (Ano % 4 > 0)"
  276. ShowHTMLCR " if ((Dia > 28) || (Dia < 1))"
  277. ShowHTMLCR " blnis = false;"
  278. ShowHTMLCR " else"
  279. ShowHTMLCR " if ((Dia > 29) || (Dia < 1))"
  280. ShowHTMLCR " blnis = false;break"
  281. ShowHTMLCR " }"
  282. ShowHTMLCR " if (Ano > dataatual.getFullYear() + 60){"
  283. ShowHTMLCR " blnis = false;}"
  284. ShowHTMLCR " }"
  285. ShowHTMLCR " else"
  286. ShowHTMLCR " blnis = false;"
  287. ShowHTMLCR " return blnis;"
  288. ShowHTMLCR "}"
  289. ShowHTMLCR "function todate(text){"
  290. ShowHTMLCR "var Dia, Mes, Ano, data;"
  291. ShowHTMLCR " data = new Date();"
  292. ShowHTMLCR " text = normalize(text);"
  293. ShowHTMLCR " Mes = data.getMonth() + 1"
  294. ShowHTMLCR " Ano = data.getFullYear()"
  295. ShowHTMLCR " if (text.length > 1){"
  296. ShowHTMLCR " Dia = parseFloat(left(text, 2));}"
  297. ShowHTMLCR " if (text.length > 3){"
  298. ShowHTMLCR " Mes = parseFloat(mid(text, 3,2));}"
  299. ShowHTMLCR " if (text.length > 5){"
  300. ShowHTMLCR " Ano = parseFloat(midtoend(text, 5));}"
  301. ShowHTMLCR " if (Ano < 100){"
  302. ShowHTMLCR " if (Ano + 1900 > data.getFullYear() - 70)"
  303. ShowHTMLCR " Ano += 1900;"
  304. ShowHTMLCR " else"
  305. ShowHTMLCR " Ano += 2000;"
  306. ShowHTMLCR " }"
  307. ShowHTMLCR " data = new Date(Ano, Mes - 1, Dia);"
  308. ShowHTMLCR " return data"
  309. ShowHTMLCR " }"
  310. ShowHTMLCR "function datetostring(data){ return leadingzeroes(data.getDate().toString(), 2) + ""/"" + leadingzeroes((data.getMonth() + 1).toString(), 2) + ""/"" + leadingzeroes(data.getFullYear(), 2);}"
  311. JavaScriptEnd
  312. End Sub
  313. REM -------------------------------------------------------------------------
  314. REM Final da Sub StrExtBegin
  315. REM -------------------------------------------------------------------------
  316. REM Entra FormJavaVerEscolha
  317. REM -------------------------------------------------------------------------
  318. Private Sub FormJavaVerEscolha(ByVal strField, strForm, strFunctionName)
  319. JavaScriptBegin
  320. ShowHTMLCR "function " & strFunctionName & "(){"
  321. ShowHTMLCR "if (document." & strForm & "." & strField & ".value == ""00""){"
  322. ShowHTMLCR "alert(""Uma das op??es deve ser escolhida"");"
  323. ShowHTMLCR "document." & strForm & "." & strField & ".focus();"
  324. ShowHTMLCR "return false;"
  325. ShowHTMLCR "}"
  326. ShowHTMLCR "return true;"
  327. ShowHTMLCR "}"
  328. JavaScriptEnd
  329. End Sub
  330. REM -------------------------------------------------------------------------
  331. REM Final da Sub FormJavaVerEscolha
  332. REM -------------------------------------------------------------------------
  333. REM Entra FormJavaVerEscolha
  334. REM -------------------------------------------------------------------------
  335. Private Sub FormJavaDataEscolha(ByVal strField, strField2, strField3, strForm, strFunctionName, strMessage)
  336. FormJavaVerEscolha strField3, strForm, strFunctionName & "VerEscolha"
  337. FormJavaCompareDate strField, strField2, strForm, strFunctionName & "CompareData", strMessage
  338. JavaScriptBegin
  339. ShowHTMLCR "function " & strFunctionName & "(){"
  340. ShowHTMLCR "return (" & strFunctionName & "VerEscolha()&&" & strFunctionName & "CompareData())"
  341. ShowHTMLCR "}"
  342. JavaScriptEnd
  343. End Sub
  344. REM -------------------------------------------------------------------------
  345. REM Final da Sub FormJavaVerEscolha
  346. REM -------------------------------------------------------------------------
  347. REM Entra FormJavaCompareDate
  348. REM -------------------------------------------------------------------------
  349. Private Sub FormJavaCompareDate(ByVal strField, strField2, strForm, strFunctionName, strMessage)
  350. JavaScriptBegin
  351. ShowHTMLCR "function " & strFunctionName & "(){"
  352. ShowHTMLCR "var datainicio, datafim, text, text2;"
  353. ShowHTMLCR "datainicio = new Date();"
  354. ShowHTMLCR "datafim = new Date();"
  355. ShowHTMLCR "text = document." & strForm & "." & strField & ".value;"
  356. ShowHTMLCR "text2 = document." & strForm & "." & strField2 & ".value;"
  357. ShowHTMLCR "if (text > """")"
  358. ShowHTMLCR "if (!isdate(text)){"
  359. ShowHTMLCR "alert(""Data Inv?lida"");"
  360. ShowHTMLCR "document." & strForm & "." & strField & ".focus();"
  361. ShowHTMLCR "return false;"
  362. ShowHTMLCR "}"
  363. ShowHTMLCR "else{"
  364. ShowHTMLCR "datainicio = todate(text);"
  365. ShowHTMLCR "document." & strForm & "." & strField & ".value = datetostring(datainicio);"
  366. ShowHTMLCR "}"
  367. ShowHTMLCR "if (text2 > """")"
  368. ShowHTMLCR "if (!isdate(text2)){"
  369. ShowHTMLCR "alert(""Data Inv?lida"");"
  370. ShowHTMLCR "document." & strForm & "." & strField2 & ".focus();"
  371. ShowHTMLCR "return false;"
  372. ShowHTMLCR "}"
  373. ShowHTMLCR "else{"
  374. ShowHTMLCR "datafim = todate(text2);"
  375. ShowHTMLCR "document." & strForm & "." & strField2 & ".value = datetostring(datafim);"
  376. ShowHTMLCR "}"
  377. ShowHTMLCR "if ((text > """") && (text2 > """")){"
  378. ShowHTMLCR "if (datainicio.valueOf() > datafim.valueOf()) {"
  379. ShowHTMLCR "alert(""" & strMessage & """);"
  380. ShowHTMLCR "document." & strForm & "." & strField & ".focus();"
  381. ShowHTMLCR "return false;"
  382. ShowHTMLCR "}}"
  383. ShowHTMLCR "return true;"
  384. ShowHTMLCR "}"
  385. JavaScriptEnd
  386. End Sub
  387. REM -------------------------------------------------------------------------
  388. REM Final da Sub FormJavaCompareDate
  389. REM -------------------------------------------------------------------------
  390. REM Entra FormJavaCompareDateSep
  391. REM -------------------------------------------------------------------------
  392. Private Sub FormJavaCompareDateSep(ByVal strField, strField2, strField3, strField4, strField5, strField6, strForm , strFunctionName, strMessage, blnMaiorQueHoje, strMessage2)
  393. JavaScriptBegin
  394. ShowHTMLCR "function " & strFunctionName & "(){"
  395. ShowHTMLCR "var datainicio, datafim, dataatual, text, text2;"
  396. ShowHTMLCR "datainicio = new Date();"
  397. ShowHTMLCR "datafim = new Date();"
  398. ShowHTMLCR "if ((document." & strForm & "." & strField & ".value > """") && (document." & strForm & "." & strField2 & ".value > """") && (document." & strForm & "." & strField3 & ".value > """")){"
  399. ShowHTMLCR "text = document." & strForm & "." & strField & ".value + document." & strForm & "." & strField2 & ".value + document." & strForm & "." & strField3 & ".value;"
  400. ShowHTMLCR "if (!isdate(text)){"
  401. ShowHTMLCR "alert(""Data Inv?lida"");"
  402. ShowHTMLCR "document." & strForm & "." & strField & ".focus();"
  403. ShowHTMLCR "return false;"
  404. ShowHTMLCR "}}"
  405. ShowHTMLCR "if ((document." & strForm & "." & strField4 & ".value > """") && (document." & strForm & "." & strField5 & ".value > """") && (document." & strForm & "." & strField6 & ".value > """")){"
  406. ShowHTMLCR "text2 = document." & strForm & "." & strField4 & ".value + document." & strForm & "." & strField5 & ".value + document." & strForm & "." & strField6 & ".value;"
  407. ShowHTMLCR "if (!isdate(text2)){"
  408. ShowHTMLCR "alert(""Data Inv?lida"");"
  409. ShowHTMLCR "document." & strForm & "." & strField4 & ".focus();"
  410. ShowHTMLCR "return false;"
  411. ShowHTMLCR "}}"
  412. ShowHTMLCR "if ((text > """") && (text2 > """")){"
  413. ShowHTMLCR "datainicio = todate(text);"
  414. ShowHTMLCR "datafim = todate(text2);"
  415. If blnMaiorQueHoje Then
  416. ShowHTMLCR "dataatual = new Date();"
  417. ShowHTMLCR "if (datainicio.valueOf() + 90000000 < dataatual.valueOf()) {"
  418. ShowHTMLCR "alert(""" & strMessage2 & """);"
  419. ShowHTMLCR "return false;"
  420. ShowHTMLCR "}"
  421. End If
  422. ShowHTMLCR "if (datainicio.valueOf() > datafim.valueOf()) {"
  423. ShowHTMLCR "alert(""" & strMessage & """);"
  424. ShowHTMLCR "document." & strForm & "." & strField & ".focus();"
  425. ShowHTMLCR "return false;"
  426. ShowHTMLCR "}}"
  427. ShowHTMLCR "return true;"
  428. ShowHTMLCR "}"
  429. JavaScriptEnd
  430. End Sub
  431. REM -------------------------------------------------------------------------
  432. REM Final da Sub FormJavaCompareDateSep
  433. REM -------------------------------------------------------------------------
  434. REM Testa se e um CPF
  435. REM -------------------------------------------------------------------------
  436. Function IsCPF(ByVal strCPF)
  437. Dim intSoma, i, strNumber, IntDigit1, IntDigit2, intMultiply, intNet
  438. If strCPF > "" Then
  439. intSoma = 0
  440. intMultiply = 10
  441. strCPF = TotalNormalizeString(strCPF)
  442. strCPF = leadingzeroes(strCPF, 11)
  443. For i = 1 To 9
  444. strNumber = Int(Mid(strCPF, i, 1))
  445. intSoma = intSoma + (strNumber * intMultiply)
  446. intMultiply = intMultiply - 1
  447. Next
  448. intNet = intSoma Mod 11
  449. If (intNet = 0) Or (intNet = 1) Then
  450. IntDigit1 = 0
  451. Else
  452. IntDigit1 = CInt(11 - intNet)
  453. End If
  454. If IntDigit1 = Int(Mid(strCPF, 10, 1)) Then
  455. intSoma = 0
  456. intMultiply = 11
  457. For i = 1 To 10
  458. strNumber = Int(Mid(strCPF, i, 1))
  459. intSoma = intSoma + (strNumber * intMultiply)
  460. intMultiply = intMultiply - 1
  461. Next
  462. intNet = intSoma Mod 11
  463. If (intNet = 0) Or (intNet = 1) Then
  464. IntDigit2 = 0
  465. Else
  466. IntDigit2 = 11 - intNet
  467. End If
  468. If IntDigit2 = Int(Mid(strCPF, 11, 1)) Then
  469. IsCPF = True
  470. Else
  471. IsCPF = False
  472. End If
  473. Else
  474. IsCPF = False
  475. End If
  476. strCPF = ZTIFormatCGC(strCPF)
  477. Else
  478. IsCPF = True
  479. End If
  480. End Function
  481. REM -------------------------------------------------------------------------
  482. REM Testa se e um CGC
  483. REM -------------------------------------------------------------------------
  484. Function IsCGC(strCGC)
  485. Dim intSoma, i, strNumber, IntDigit1, IntDigit2, intMultiply, intNet
  486. If strCGC > "" Then
  487. intMultiply = 5
  488. intSoma = 0
  489. strCGC = TotalNormalizeString(strCGC)
  490. strCGC = leadingzeroes(strCGC, 14)
  491. For i = 1 To 12
  492. strNumber = Int(Mid(strCGC, i, 1))
  493. intSoma = intSoma + (intMultiply * strNumber)
  494. intMultiply = intMultiply - 1
  495. If intMultiply < 2 Then
  496. intMultiply = 9
  497. End If
  498. Next
  499. intNet = intSoma Mod 11
  500. If (intNet = 0) Or (intNet = 1) Then
  501. IntDigit1 = 0
  502. Else
  503. IntDigit1 = 11 - intNet
  504. End If
  505. If IntDigit1 = Int(Mid(strCGC, 13, 1)) Then
  506. intMultiply = 6
  507. intSoma = 0
  508. For i = 1 To 13
  509. strNumber = Int(Mid(strCGC, i, 1))
  510. intSoma = intSoma + (intMultiply * strNumber)
  511. intMultiply = intMultiply - 1
  512. If intMultiply < 2 Then
  513. intMultiply = 9
  514. End If
  515. Next
  516. intNet = intSoma Mod 11
  517. If (intNet = 0) Or (intNet = 1) Then
  518. IntDigit2 = 0
  519. Else
  520. IntDigit2 = 11 - intNet
  521. End If
  522. If IntDigit2 = Int(Mid(strCGC, 14, 1)) Then
  523. IsCGC = True
  524. Else
  525. IsCGC = False
  526. End If
  527. Else
  528. IsCGC = False
  529. End If
  530. Else
  531. IsCGC = True
  532. End If
  533. End Function
  534. REM ---------------------------------------------------------------------
  535. REM Fim do /ZTITools/CPF.inc
  536. REM -------------------------------------------------------------------------
  537. REM Testa um Email
  538. REM -------------------------------------------------------------------------
  539. Function IsEmail(ByVal strEmail)
  540. IsEmail = ((InStr(strEmail, "@") <> 0) And (InStr(strEmail, ".") <> 0) And (InStr(strEmail, " ") = 0)) Or (Not strEmail > "")
  541. End Function
  542. REM ---------------------------------------------------------------------
  543. REM Fim do IsEmail
  544. REM -------------------------------------------------------------------------
  545. REM Testa uma Data
  546. REM -------------------------------------------------------------------------
  547. Function IsValidDate(ByVal strDate)
  548. Dim Dia, Mes, Ano, blnIsDate
  549. blnIsDate = True
  550. If Not LCase(TypeName(strDate)) = "date" Then
  551. If strDate > "" Then
  552. strDate = NormalizeString(strDate)
  553. Mes = Month(Now)
  554. Ano = Year(Now)
  555. If Len(strDate) > 1 Then
  556. Dia = CInt(Left(strDate, 2))
  557. If Len(strDate) > 2 Then
  558. Mes = CInt(Mid(strDate, 3, 2))
  559. End If
  560. If Len(strDate) > 4 Then
  561. Ano = CInt(Mid(strDate, 5, 4))
  562. End If
  563. If (Mes > 12) Or (Mes < 1) Then
  564. blnIsDate = False
  565. End If
  566. If (Dia < 1) Or (Dia > MonthSize(Mes, Ano)) Then
  567. blnIsDate = False
  568. End If
  569. If (Ano > Year(Now) + 60) Then
  570. blnIsDate = False
  571. End If
  572. Else
  573. blnIsDate = False
  574. End If
  575. End If
  576. End If
  577. IsValidDate = blnIsDate
  578. End Function
  579. REM ---------------------------------------------------------------------
  580. REM Fim do IsDate
  581. REM -------------------------------------------------------------------------
  582. REM Testa uma Hora
  583. REM -------------------------------------------------------------------------
  584. Function IsValidTime(ByVal strTime)
  585. Dim Hora, Minuto, blnIsTime
  586. blnIsTime = True
  587. If strTime > "" Then
  588. strTime = NormalizeString(strTime)
  589. Minuto = 0
  590. Hora = CInt(Left(strTime, 2))
  591. If Len(strTime) > 2 Then
  592. Minuto = CInt(Mid(strTime, 3, 2))
  593. End If
  594. If (Hora > 23) Then
  595. blnIsTime = False
  596. End If
  597. If (Minuto > 59) Then
  598. blnIsTime = False
  599. End If
  600. strTime = LeadingZeroes(Hora, 2) & ":" & LeadingZeroes(Minuto, 2)
  601. End If
  602. REM ShowJavaScriptMessage strTime
  603. IsValidTime =blnIsTime
  604. End Function
  605. REM ---------------------------------------------------------------------
  606. REM Fim do IsValidTime
  607. REM -------------------------------------------------------------------------
  608. REM Formata uma Hora
  609. REM -------------------------------------------------------------------------
  610. Function FormatTime(strTime)
  611. Dim Hora, Minuto
  612. strTime = NormalizeString(strTime)
  613. Minuto = 0
  614. Hora = CInt(Left(strTime, 2))
  615. If Len(strTime) > 2 Then
  616. Minuto = CInt(Mid(strTime, 3, 2))
  617. End If
  618. strTime = LeadingZeroes(Hora, 2) & ":" & LeadingZeroes(Minuto, 2)
  619. FormatTime = strTime
  620. End Function
  621. REM ---------------------------------------------------------------------
  622. REM Fim do FormatTime
  623. REM -------------------------------------------------------------------------
  624. REM
  625. REM -------------------------------------------------------------------------
  626. Private Function CompareDate(ByVal strDate, strDate2)
  627. Dim dtmDataInicio, dtmDataFim, intCompare
  628. intCompare = 0
  629. If strDate > "" Then
  630. If IsValidDate(strDate) Then
  631. dtmDataInicio = CDate(strDate)
  632. Else
  633. intCompare = 1
  634. End If
  635. End If
  636. If strDate2 > "" Then
  637. If IsValidDate(strDate2) Then
  638. dtmDataFim = CDate(strDate2)
  639. Else
  640. intCompare = intCompare + 2
  641. End If
  642. End If
  643. If intCompare = 0 Then
  644. If strDate > "" And strDate2 > "" Then
  645. If dtmDataInicio > dtmDataFim Then
  646. intCompare = 4
  647. End If
  648. End If
  649. End If
  650. CompareDate = intCompare
  651. End Function
  652. REM -------------------------------------------------------------------------
  653. REM Final da Sub CompareDate
  654. REM -------------------------------------------------------------------------
  655. REM Retorna o Tamanho de um Mes
  656. REM -------------------------------------------------------------------------
  657. Function MonthSize(intMes, intAno)
  658. Select Case intMes
  659. Case 1,3,5,7,8,10,12
  660. MonthSize = 31
  661. Case 4,6,9,11
  662. MonthSize = 30
  663. Case 2
  664. If intAno Mod 4 = 0 Then
  665. MonthSize = 29
  666. Else
  667. MonthSize = 28
  668. End If
  669. End Select
  670. End Function
  671. REM -------------------------------------------------------------------------
  672. REM Final da Function MonthSize
  673. %>