//========================================================
//VALIDAÇÃO DE FORMULÁRIO
//========================================================
//--------------------------------------------------------
//Formatação e validação de CNPJ
//Colocar onKeyUp="cnpjnumber(this)" no campo do formulário
//Formatar o campo com 18 caracteres
//Mesclar esta função com a função com a formatação de
//campo somente numérico
//--------------------------------------------------------
function cnpjnumber(elemento){
var cnpjnumber
if (elemento.value.length > 0 )
{
if (elemento.value.length == 2)
{
cnpjnumber = elemento.value;
elemento.value = cnpjnumber + '.';
elemento.focus();
}
if (elemento.value.length == 6)
{
cnpjnumber = elemento.value;
elemento.value = cnpjnumber + '.';
elemento.focus();
}
if (elemento.value.length == 10)
{
cnpjnumber = elemento.value;
elemento.value = cnpjnumber + '/';
elemento.focus();
}
if (elemento.value.length == 15)
{
cnpjnumber = elemento.value;
elemento.value = cnpjnumber + '-';
elemento.focus();
}
}
return 0;
}
//--------------------------------------------------------
//Formatação e validação de CPF
//Colocar onKeyUp="cpfnumber(this)" no campo do formulário
//Formatar o campo com 14 caracteres
//Mesclar esta função com a função com a formatação de
//campo somente numérico
//--------------------------------------------------------
function cpfnumber(elemento){
var cpfnumber
if (elemento.value.length > 0 )
{
if (elemento.value.length == 3)
{
cpfnumber = elemento.value;
elemento.value = cpfnumber + '.';
elemento.focus();
}
if (elemento.value.length == 7)
{
cpfnumber = elemento.value;
elemento.value = cpfnumber + '.';
elemento.focus();
}
if (elemento.value.length == 11)
{
cpfnumber = elemento.value;
elemento.value = cpfnumber + '-';
elemento.focus();
}
}
return 0;
}
//--------------------------------------------------------
//Formatação e validação de número de telefone
//Colocar onKeyUp="tel(this)" no campo do formulário
//Formatar o campo com 14 caracteres
//Mesclar esta função com a função com a formatação de
//campo somente numérico
//--------------------------------------------------------
function tel(elemento){
var telefone
if (elemento.value.length > 0 )
{
if (elemento.value.length == 1)
{
telefone = elemento.value;
elemento.value = '(' + telefone;
elemento.focus();
}
if (elemento.value.length == 3)
{
telefone = elemento.value;
elemento.value = telefone + ') ';
elemento.focus();
}
}
return 0;
}
//--------------------------------------------------------
//Formatação e validação de datas
//Colocar onKeyUp="data(this)" no campo do formulário
//Formatar o campo com 10 Caracteres
//Mesclar esta função com a função com a formatação de
//campo somente numérico
//--------------------------------------------------------
function data(elemento){
var data
if (elemento.value.length > 0 )
{
if (elemento.value.length == 2)
{
data = elemento.value;
elemento.value = data + '/';
elemento.focus();
}
if (elemento.value.length == 5)
{
data = elemento.value;
elemento.value = data + '/';
elemento.focus();
}
}
return 0;
}
//--------------------------------------------------------
//Campo somente numérico
// Colocar OnKeyPress="numerico();" no campo do formulário
//--------------------------------------------------------
function numerico() { 
if (event.keyCode == '13') 
{ 
} 
else if (event.keyCode < '48' || event.keyCode > '58') 
{ 
alert('Neste campo digite apenas números!'); 
event.keyCode = '127'; 
} 
} 
//========================================================
//INCLUSÃO DE ARQUIVOS SWF
//========================================================
//--------------------------------------------------------
//Na página, incluir os arquivos SWF desta maneira:
//<script> 
//EscreveFlash(LARGURA, ALTURA, "arquivo.swf");
//< / script>  (sem os espaços)
//--------------------------------------------------------
function EscreveFlash(piWid, piHei, psSrc, psId)
{
var strSwf;

strSwf = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" id="+psId+" width="+piWid+" height="+piHei+">";
strSwf += "<param name=\"movie\" value=\""+psSrc+"\"' />";
strSwf += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
strSwf += "<param name=\"quality\" value=\"high\" />";
strSwf += "<param name=\"wmode\" value=\"transparent\" />";
strSwf += "<embed id="+psId+" name="+psId+" allowScriptAccess=\"sameDomain\" swLiveConnect=\"true\" src=\""+psSrc+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width="+piWid+" height="+piHei+"></embed></object>";

this.document.write(strSwf);
} 