Ao utilizar a tag CFFORM - portanto isso se aplica também ao CFINPUT e
ao CFSELECT, é necessário que o browser consiga acessar o diretório
/CFIDE/scripts, onde está localizado o arquivo de JavaScript utilizado
na tag CFFORM. Isso não quer dizer que você precisa ter o diretóprio
CFIDE inteiro (nem o /CFIDE/Administrator/), mas apenas o CFIDE/scripts,
com os arquivos de JavaScript dentro dele. Não há riscos de segurança
ter esse diretório disponível e não há necessidade de pedir ao provedor
para fazê-lo, você mesmo pode criar esse diretório em seu web root.
Boa sorte!
Fabio Teracini
<Marcio> wrote:
É o jeito né?!
Valeu!!!
-----Original Message-----
From: bruno|bucci [mailto:[EMAIL PROTECTED]
Sent: segunda-feira, 28 de junho de 2004 12:06
To: [EMAIL PROTECTED]
Subject: Re: [cf-brasil] cfinput x javascript
Marcio,
Eu tive o mesmo problema mas optei por usar somente javascript !! Também
pq a criação de um um formulário usando <cf é um pouco mais lenta !
----- Original Message -----
From: <Marcio> <[EMAIL PROTECTED]>
Date: Mon, 28 Jun 2004 11:30:34 -0300
Subject: [cf-brasil] cfinput x javascript
To: [EMAIL PROTECTED]
Estou tentando fazer a validacao de um form sendo que alguns itens eu
valido pelo cfinput (required="Yes" message="Informe o campo") e outros
itens valido por uma funcao javascript.
O mais interessante é que, em um de nossos servidores a validação
utilizando os 2 funciona normalmente. No outro servidor dá erro de
javascript
Instalamos recentemente a atualizacao do CF nos 2 servidores. Estou
testando de diversas maquinas e acontece o mesmo em todas!
Vejam o source
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<head> <title>Untitled Document</title> <meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1"> </head> <cfinclude
template="qry_cadastro.cfm"> <body bgcolor="F2F2F2"> <cfif
qryparticipant.recordcount is 0><cfabort></cfif> <cfform
action="index.cfm" method="post" name="frmcadastro" enablecab="no"
onSubmit="return valida();"> <input type="hidden" name="fuseaction"
value="cadastro.save"> <input type="hidden" name="stTpFunc" value="U">
<cfoutput><input type="hidden" name="inParticipantID"
value="#qryparticipant.inParticipantID#"></cfoutput>
<table cellpadding="1" cellspacing="1" border="0" class="txt1"
width="478" bgcolor="D6C8AF" style="table-layout:fixed;"> <tr>
<td><span style="color:red; font-size:8pt;
font-family:verdana;">*</span> Campos obrigatórios
<table class="normal">
<tr>
<td nowrap><strong>Nome:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td colspan="3"><cfinput name="stName" type="text"
value="#qryparticipant.stName#" size="40" maxlength="100" required="yes"
message="Informe o nome" class="normal"></td>
</tr>
<tr>
<td nowrap><strong>Apelido:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td><cfinput name="stNickName" type="text"
value="#qryparticipant.stNickName#" size="35" maxlength="100"
required="yes" message="Informe o apelido" class="normal">
<strong>Sexo:</strong> <span style="color:red; font-size:8pt;
font-family:verdana;">*</span>
<select name="stSexID" class="normal">
<option value="0" selected>Selecione</option>
<cfoutput query="qrysex">
<cfif stSexID is qryparticipant.stSexID>
<option value="#stSexID#" selected>#stSex#</option>
<cfelse>
<option value="#stSexID#">#stSex#</option>
</cfif>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td nowrap><strong>E-Mail:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td><cfinput name="stEmail" type="text"
value="#qryparticipant.stEmail#" size="40" maxlength="100"
class="normal"></td>
</tr>
<tr>
<td nowrap><strong>Cargo:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td nowrap><cfinput name="stPosition" type="text"
value="#qryparticipant.stPosition#" size="40" maxlength="100"
class="normal" required="Yes" message="Informe o cargo"></td>
</tr>
<tr>
<td nowrap><strong>Empresa:</strong></td>
<td nowrap><input type="text" size="62"
value="<cfoutput>#qryparticipant.stCompany#</cfoutput>" class="normal"
disabled></td>
</tr>
<tr>
<td><strong>RG:</strong> <span style="color:red; font-size:8pt;
font-family:verdana;">*</span></td>
<td><cfinput name="stRG" type="text" value="#qryparticipant.stRG#"
size="20" maxlength="20" class="normal" required="Yes" message="Informe
o RG">
<strong>CPF:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span>
<cfinput name="stCpf" type="text" value="#qryparticipant.stcpf#"
size="20" maxlength="20" class="normal"
passthrough="#iif(qryparticipant.stcpf is "", de(""), de("readonly"))#"
required="Yes" message="Informe o CPF"></td>
</tr>
<tr>
<td nowrap><strong>Endereço:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td><cfinput name="stAddress" type="text"
value="#qryparticipant.stAddress#" size="40" maxlength="100"
class="normal" required="Yes" message="Informe o endereço">
<strong>Nº:</strong> <span style="color:red; font-size:8pt;
font-family:verdana;">*</span> <cfinput name="stAdd_number" type="text"
value="#qryparticipant.stAdd_number#" size="10" maxlength="10"
class="normal" required="Yes" message="Informe o número do endereço">
</td>
</tr>
<tr>
<td nowrap><strong>Complemento:</strong></td>
<td><cfinput name="stAdd_complement" type="text"
value="#qryparticipant.stAdd_Complement#" size="20" maxlength="40"
class="normal">
<strong>Bairro:</strong> <span style="color:red; font-size:8pt;
font-family:verdana;">*</span>
<cfinput name="stQuarter" type="text"
value="#qryparticipant.stQuarter#" size="20" maxlength="40"
class="normal" required="Yes" message="Informe o bairro"></td>
</tr>
<tr>
<td nowrap><strong>Cidade:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td><cfinput name="stCity" type="text"
value="#qryparticipant.stCity#" size="25" maxlength="50" class="normal"
required="Yes" message="Informe a cidade">
<strong>UF:</strong> <cfinput name="stState" type="text"
value="#qryparticipant.stState#" size="2" maxlength="2"
class="normal">
<strong>CEP:</strong> <cfinput name="stZipCode" type="text"
value="#qryparticipant.stZipCode#" size="10" maxlength="10"
class="normal">
</td>
</tr>
<tr>
<td nowrap><strong>Telefone </strong><font
size="-4">(DDD/No.)</font><strong>:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td><cfinput name="stDDDPhone" type="text"
value="#qryparticipant.stDDDPhone#" size="3" maxlength="3"
class="normal">
<cfinput name="stPhone" type="text" value="#qryparticipant.stPhone#"
size="15" maxlength="30" class="normal" required="Yes" message="Informe
o telefone">
<strong>Fax:</strong>
<cfinput name="stDDDFax" type="text"
value="#qryparticipant.stDDDFax#" size="3" maxlength="3" class="normal">
<cfinput name="stFax" type="text" value="#qryparticipant.stFax#"
size="15" maxlength="30" class="normal"></td>
</tr>
<tr>
<td nowrap><strong>Celular </strong><font
size="-4">(DDD/No.)</font><strong>:</strong></td>
<td><cfinput name="stDDDCel" type="text"
value="#qryparticipant.stDDDCell#" size="3" maxlength="3"
class="normal">
<cfinput name="stCell" type="text" value="#qryparticipant.stCel#"
size="15" maxlength="30" class="normal">
<strong>Filhos:</strong><cfinput name="inChildrens_M"
type="text" value="#qryparticipant.inChildrens_M#" size="2"
maxlength="2" required="no" validate="integer" class="normal">
<strong>Filhas:</strong><cfinput name="inChildrens_F"
type="text" value="#qryparticipant.inChildrens_F#" size="2"
maxlength="2" required="no" validate="integer" class="normal">
</td>
</tr>
<tr>
<td nowrap><strong>Estado Civil:</strong></td>
<td><select name="inMarriageTypeId" class="normal"
style="width:130px">
<option value="0" selected>Selecione</option>
<cfoutput query="qryMarriageType">
<cfif inMarriageTypeId is qryparticipant.inMarriageTypeId>
<option value="#inMarriageTypeId#" selected>#stMarriage#</option>
<cfelse>
<option value="#inMarriageTypeId#">#stMarriage#</option>
</cfif>
</cfoutput>
</select>
<strong>Dt. Nascimento:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span>
<cfinput name="dtBirthDate" type="text"
value="#qryparticipant.dtBirthDate#" size="7" maxlength="5"
required="Yes" message="Informe a Data de Nascimento (dd/mm)"
class="normal">
</td>
</tr>
<tr>
<td nowrap><strong>Time:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td><select name="inTeamId" class="normal" style="width:130px">
<option value="0" selected>Selecione</option>
<cfoutput query="qryTeam">
<cfif inTeamId is qryparticipant.inTeamId>
<option value="#inTeamId#" selected>#stTeam#</option>
<cfelse>
<option value="#inTeamId#">#stTeam#</option>
</cfif>
</cfoutput>
</select>
<strong>Hobby: </strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span>
<select name="inHobbyId" class="normal" style="width:130px">
<option value="0" selected>Selecione</option>
<cfoutput query="qryHobby">
<cfif inHobbyId is qryparticipant.inHobbyId>
<option value="#inHobbyId#" selected>#stHobby#</option>
<cfelse>
<option value="#inHobbyId#">#stHobby#</option>
</cfif>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td nowrap><strong>Comida:</strong> <span style="color:red;
font-size:8pt; font-family:verdana;">*</span></td>
<td><select name="inFoodId" class="normal" style="width:130px">
<option value="0" selected>Selecione</option>
<cfoutput query="qryFood">
<cfif inFoodId is qryparticipant.inFoodId>
<option value="#inFoodId#" selected>#stFood#</option>
<cfelse>
<option value="#inFoodId#">#stFood#</option>
</cfif>
</cfoutput>
</select>
<strong>Música:</strong> <span style="color:red; font-size:8pt;
font-family:verdana;">*</span>
<select name="inMusicId" class="normal" style="width:130px">
<option value="0" selected>Selecione</option>
<cfoutput query="qryMusic">
<cfif inMusicId is qryparticipant.inMusicId>
<option value="#inMusicId#" selected>#stMusic#</option>
<cfelse>
<option value="#inMusicId#">#stMusic#</option>
</cfif>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td nowrap valign="top"><strong>Observação:</strong></td>
<td><textarea name="stRemarks" cols="60" rows="5"
class="normal"><cfoutput>#qryparticipant.stRemarks#</cfoutput></textarea
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"> <cfif len(attributes.msg) gt
0><cfoutput><strong>#attributes.msg#</strong></cfoutput></cfif></td>
</tr>
<tr>
<td align="center" class="tabela_tit2"><input type="submit"
value="Salvar" class="submit"><!--- <a
href="javascript:document.frmcadastro.submit();"><font
color="000000"><strong>Salvar</strong></font></a> ---></td> </tr>
</table> </cfform> <script>
function valida() {
var Form, URL;
Form = document.frmcadastro;
URL = document.URL.toString();
/*if(Form.action[0].checked) {
if (Form.id_cat_mail.value.length == 0) {
alert("Informe sua área de atuação !");
Form.id_cat_mail.focus();
return false;
}
}*/
if (Form.stSexID.value == 0) {
alert("Informe o sexo");
Form.stSexID.focus();
return false;
}
if (Form.inTeamId.value == 0) {
alert("Informe o time que torce");
Form.inTeamId.focus();
return false;
}
if (Form.inHobbyId.value == 0) {
alert("Informe o hobby");
Form.inHobbyId.focus();
return false;
}
if (Form.inFoodId.value == 0) {
alert("Informe a comida preferida");
Form.inFoodId.focus();
return false;
}
if (Form.inMusicId.value == 0) {
alert("Informe o estilo musical");
Form.inMusicId.focus();
return false;
}
if (Form.stCpf.value.length == 0) {
alert("Informe o CPF");
Form.stCpf.focus();
return false;
}
/* validacao de CPF */
s = limpa_string(Form.stCpf.value);
// checa se é cpf
if (s.length == 11) {
if (valida_CPF(Form.stCpf.value) == false || (Form.stCpf.value ==
11111111111)) {
alert("O CPF não é válido !");
Form.stCpf.focus();
return false;
}
}
// checa se é cgc
else if (s.length == 14) {
if (valida_CGC(Form.stCpf.value) == false ) {
alert("O CGC não é válido !");
Form.stCpf.focus();
return false;
}
}
else {
alert("O CPF não é válido !");
return false;
}
if (Form.stEmail.value.length == 0) {
alert("Informe o email");
Form.stEmail.focus();
return false;
} else {
return checkEmail(Form.stEmail.value);
}
return true;
}
function limpa_string(S){
// Deixa so' os digitos no numero
var Digitos = "0123456789";
var temp = "";
var digito = "";
for (var i=0; i<S.length; i++){
digito = S.charAt(i);
if (Digitos.indexOf(digito)>=0){temp=temp+digito}
}
return temp
}
function valida_CPF(s)
{
var i;
s = limpa_string(s);
var c = s.substr(0,9);
var dv = s.substr(9,2);
var d1 = 0;
for (i = 0; i < 9; i++)
{
d1 += c.charAt(i)*(10-i);
}
if (d1 == 0) return false;
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1)
{
return false;
}
d1 *= 2;
for (i = 0; i < 9; i++)
{
d1 += c.charAt(i)*(11-i);
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(1) != d1)
{
return false;
}
return true;
}
function checkEmail(myForm) {
if
(/^\w+([\.-]?\w+)[EMAIL PROTECTED]([\.-]?\w+)*(\.\w{2,3})+$/.test(frmcadastro.stEmai
l.value)){
return (true)
}
if (document.frmcadastro.stEmail.value.length != 0) {
alert("Email inválido. Digite novamente !")
document.frmcadastro.stEmail.focus();
return (false)
}
}
document.frmcadastro.stName.focus();
</script>
</body>
--^----------------------------------------------------------------
This email was sent to: [EMAIL PROTECTED]
EASY UNSUBSCRIBE click here: http://topica.com/u/?b1dnXn.b7M5gI.YXJxdWl2
Or send an email to: [EMAIL PROTECTED]
For Topica's complete suite of email marketing solutions visit:
http://www.topica.com/?p=TEXFOOTER
--^----------------------------------------------------------------