<mySearch ⁄>
<mySnippets order="rand" ⁄>
<myContacts ⁄><email ⁄>
<windows live messenger ⁄>
<myCurriculum type="pdf" ⁄>
<myBlog show="last" ⁄>
<myNews show="rand" ⁄>
<myNews type="cat" ⁄>
<myQuote order="random" ⁄>Servir os outros, torna-nos livres em nós mesmos.
<myPhoto order="random" ⁄>
<myAdSense ⁄>
<myVisitorsMap ⁄>
/** * Obter os n 1os caracteres de uma string * * @param String * @param int - quantos caracteres? * @return String */ function left(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); } /** * Obter os n últimos caracteres de uma string * * @param String * @param int - quantos caracteres? * @return String */ function right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } } /** * Obter uma parte intermediária da String * * @param String * @param int - começa em que posição? nota: a posição inicial é o 0 * @param int - acaba em que posição? * @return String */ function mid(str, startAt, until){ if (startAt < 0 || until < 0) return ""; var iEnd, iLen = String(str).length; if (startAt + until > iLen) iEnd = iLen; else iEnd = startAt + until; return String(str).substring(startAt,iEnd); }
/** * Verificar se uma string é composta por número e letras * * @param form - nome do formulário * @param field - nome do campo * @return String */ function isAlphanumeric(form, field){ checkStr=form.elements[field].value; var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; //caracteres válidos para a função var allValid = true; for (i = 0; i < checkStr.length; i++){ ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length){ allValid = false; break; } } return allValid; } /** * Verificar se uma string é composta por número * * @param form - nome do formulário * @param field - nome do campo * @return String */ function isNumber(form, field){ checkStr=form.elements[field].value; var checkOK = "0123456789.-"; //caracteres válidos para a função var allValid = true; for (i = 0; i < checkStr.length; i++){ ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length){ allValid = false; break; } } return allValid; }