Forums

javascript validation

cleocadio 09 Jul, 2007
Hello.

I had to migrate a form from another site to this joomla site and i've used chrono, wich is great. The problem is that the javascript does nothing. the mail is sent, formated like my template, but it goes with empty fields if i don't fill them.

the javascript pasted in the Form JavaScript:
(without the script tags)

function checkForm(form) {
	var data_nascimento = new Date(form.data_nascimento_ano.value, parseInt(form.data_nascimento_mes.value)-1, form.data_nascimento_dia.value);
	var bi_emissao = new Date(form.bi_emissao_ano.value, parseInt(form.bi_emissao_mes.value)-1, form.bi_emissao_dia.value);
	var bi_validade = new Date(form.bi_validade_ano.value, parseInt(form.bi_validade_mes.value)-1, form.bi_validade_dia.value);
	//var disponibilidade_data = new Date(form.disponibilidade_data_ano.value, parseInt(form.disponibilidade_data_mes.value)-1, form.disponibilidade_data_dia.value);
	
	if (data_nascimento.getDate() == parseInt(form.data_nascimento_dia.value))
		form.data_nascimento.value = data_nascimento.getDate()+"-"+(data_nascimento.getMonth()+1)+"-"+data_nascimento.getFullYear();
	if (bi_emissao.getDate() == parseInt(form.bi_emissao_dia.value))
		form.bi_emissao.value = bi_emissao.getDate()+"-"+(bi_emissao.getMonth()+1)+"-"+bi_emissao.getFullYear();
	if (bi_validade.getDate() == parseInt(form.bi_validade_dia.value))
		form.bi_validade.value = bi_validade.getDate()+"-"+(bi_validade.getMonth()+1)+"-"+bi_validade.getFullYear();
	//if (disponibilidade_data.getDate() == parseInt(form.disponibilidade_data_dia.value))
	//	form.disponibilidade_data.value = disponibilidade_data;

	var msg = "";

	if (form.nome.value==""«»)
		msg = "- Nome; \n";
	if (form.morada.value==""«»)
		msg += "- Morada; \n";
	if (form.localidade.value==""«»)
		msg += "- Localidade; \n";
	if (parseInt(form.cp1.value)<1000)
		msg += "- Código Postal; \n";
	if (form.contacto.value.length!=9 || parseInt(form.contacto.value)<200000000 || parseInt(form.contacto.value)>970000000)
		msg += "- Telefone; \n";
	if (form.email.value=="" || form.email.value.indexOf("@"«»)<3 || form.email.value.indexOf("@"«»)>form.email.value.lastIndexOf("."«»))
		msg += "- Email; \n";
	if (parseInt(form.data_nascimento_dia.value)!=data_nascimento.getDate() || 
		parseInt(form.data_nascimento_mes.value)-1!=data_nascimento.getMonth() || 
		parseInt(form.data_nascimento_ano.value)!=data_nascimento.getFullYear())
		msg += "- Data de Nascimento; \n";
	if (form.bi.value==""«»)
		msg += "- BI; \n";
	if (form.bi_arquivo.value==""«»)
		msg += "- Arquivo BI; \n";
	if (parseInt(form.bi_emissao_dia.value)!=bi_emissao.getDate() || 
		parseInt(form.bi_emissao_mes.value)-1!=bi_emissao.getMonth() || 
		parseInt(form.bi_emissao_ano.value)!=bi_emissao.getFullYear())
		msg += "- Emissao do BI; \n";
	if (parseInt(form.bi_validade_dia.value)!=bi_validade.getDate() || 
		parseInt(form.bi_validade_mes.value)-1!=bi_validade.getMonth() || 
		parseInt(form.bi_validade_ano.value)!=bi_validade.getFullYear())
		msg += "- Validade do BI; \n";
	if (form.naturalde.value==""«»)
		msg += "- Natural de; \n";
	if (form.nacionalidade.value==""«»)
		msg += "- Nacionalidade; \n";
	if (form.habilitacoes.value==""«»)
		msg += "- Habilitações; \n";
	if (!form.carta_conducao[0].checked && !form.carta_conducao[1].checked)
		msg += "- Carta de Condução; \n";
	if (!form.carta_mota[0].checked && !form.carta_mota[1].checked)
		msg += "- Carta de Mota; \n";
	if (!form.andar_patins[0].checked && !form.andar_patins[1].checked)
		msg += "- Andar de patins; \n";
	if (form.habilitacoes.value==""«»)
		msg += "- Habilitações; \n";
	if (form.medidas_altura.value==""«»)
		msg += "- Altura; \n";
	if (form.medidas_saia.value==""«»)
		msg += "- Medida de saia/calça; \n";
	if (form.medidas_casaco.value==""«»)
		msg += "- Medida do casaco; \n";
	if (form.medidas_sapato.value==""«»)
		msg += "- Número sapato; \n";
	if (form.disponibilidade.value==""«»)
		msg += "- Disponibilidade; \n";

	if (msg==""«»)
		return true;
	else {
		alert("Por favor verifique o preenchimento correcto dos seguintes campos:\n"+msg);
		return false;
	}
}

var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);


function show(id) {
	if (isDOM)
		document.getElementById(id).style.visibility = 'visible'; 
	if (isIE4)
		document.all[id].style.visibility = 'visible';
	if (isNS4)
		document.layers[id].visibility = 'show';
}
	
function hide(id) {
	if (isDOM)
		document.getElementById(id).style.visibility = 'hidden'; 
	if (isIE4)
		document.all[id].style.visibility = 'hidden';
	if (isNS4)
		document.layers[id].visibility = 'hide';
}
	
function showObjects() {
	var args = arguments;
	for (var i=0 ; i<args.length ; i++) {
		show(args[i]);//.style.visibility = "visible";
	}
}

function hideObjects() {
	var args = arguments;
	for (var i=0 ; i<args.length ; i++) {
		hide(args[i]);
	}
}


the html:

[code]<table width="500" height="210" border="0" align="center" cellpadding="0" cellspacing="0">

<input type="hidden" name="data_nascimento" value="">
<input type="hidden" name="bi_emissao" value="">
<input type="hidden" name="bi_validade" value="">
<input type="hidden" name="disponibilidade_data" value="">
<tr valign="middle" class="table_form">
<td height="0" colspan="3" >Todos
os campos são de preenchimento obrigatório.</td>
</tr>
<tr valign="middle" >
<td height="0" colspan="3" ><h3>Informações Pessoais </h3></td>
</tr>
<tr align="right" >
<td height="0" colspan="3" class="table_form"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td><div align="left">Nome
Completo:</div></td>
<td>
<div align="left">
<input name="nome" type="text" id="bi2824" value="" size="25" maxlength="250">
</div></td>
</tr>
<tr>
<td><div align="left">Morada:</span></div></td>
<td>
<div align="left">
<input name="morada" type="text" id="morada" value="" size="25" maxlength="250">
</div></td>
</tr>
<tr>
<td> <div align="left">Localidade:</div></td>
<td>
<div align="left">
<input name="localidade" type="text" id="localidade" size="25" maxlength="100">
</div></td>
</tr>
<tr>
<td> <div align="left">Código
Postal:</div></td>
<td>
<div align="left">
<input name="cp1" type="text" id="cp1" size="4" maxlength="4">
<input name="cp2" type="text" id="cp2" size="3" maxlength="3">
</div></td>
</tr>
<tr>
<td> <div align="left">Contacto
telefónico:</div></td>
<td>
<div align="left">
<input name="contacto" type="text" id="telefone2" size="25" maxlength="15">
</div></td>
</tr>
<tr>
<td> <div align="left">E-mail:</div></td>
<td>
<div align="left">
<input name="email" type="text" id="email2" size="25" maxlength="100">
</div></td>
</tr>
<tr>
<td> <div align="left">Data
de Nascimento:</div></td>
<td>
<div align="left">
<input name="data_nascimento_dia" type="text" id="data_nascimento_dia" size="3" maxlength="2">
/
<input name="data_nascimento_mes" type="text" id="data_nascimento_mes" size="3" maxlength="2">
/
<input name="data_nascimento_ano" type="text" id="data_nascimento_ano" size="5" maxlength="4">
</div></td>
</tr>
<tr>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<td> <div align="left">Nº
de B.I.:</div></td>
<td>
<div align="left">
<input name="bi" type="text" id="bi" size="25" maxlength="12">
</div></td>
</tr>
<tr>
<td> <div align="left">Arquivo:</div></td>
<td>
<div align="left">
<input name="bi_arquivo" type="text" id="bi_arquivo" size="25">
</div></td>
</tr>
<tr>
<td> <div align="left">De:</div></td>
<td>
<div align="left">
<input name="bi_emissao_dia" type="text" id="bi_emissao_dia" size="3" maxlength="2">
/
<input name="bi_emissao_mes" type="text" id="bi_emissao_mes" size="3" maxlength="2">
/
<input name="bi_emissao_ano" type="text" id="bi_emissao_ano" size="5" maxlength="4">
</div></td>
</tr>
<tr>
<td> <div align="left">Validade:</div></td>
<td>
<div align="left">
<input name="bi_validade_dia" type="text" id="bi_validade_dia" size="3" maxlength="2">
/
<input name="bi_validade_mes" type="text" id="bi_validade_mes" size="3" maxlength="2">
/
<input name="bi_validade_ano" type="text" id="bi_validade_ano" size="5" maxlength="4">
 </div></td>
</tr>
<tr>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<td> <div align="left">Natural
de:</div></td>
<td>
<div align="left">
<input name="naturalde" type="text" id="naturalde" size="25" maxlength="50">
</div></td>
</tr>
<tr>
<td> <div align="left">Nacionalidade:</div></td>
<td>
<div align="left">
<input name="nacionalidade" type="text" id="nacionalidade" size="25" maxlength="50">
</div></td>
</tr>
</table></td>
</tr>
<tr valign="middle" >
<td height="0" colspan="3" ><h3>Habilitação Escolar </h3></td>
</tr>

<tr valign="middle" >
<td height="0" colspan="3" class="tables"><div align="left">
<select name="habilitacoes" id="habilitacoes">
<option value="" selected>- Escolher -</option>
<option value="Básico">Básico</option>
<option value="Secundário">Secundário</option>
<option value="Bacharelato">Bacharelato</option>
<option value="Licenciatura">Licenciatura</option>
<option value="Doutoramento">Doutoramento</option>
<option value="Mestrado">Mestrado</option>
</select>
</div></td>
</tr>
<tr valign="middle" >
<td height="0" colspan="3" ><h3>Conecimentos Informáticos </h3></td>
</tr>
<tr align="right" valign="middle" >
<td height="0" colspan="3" ><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" >
<tr align="left">
<td width="30">
<div align="left">
<input name="informatica_word" type="checkbox" id="informatica_word" value="S">
</div></td>
<td> <div align="left">Word</div></td>
<td width="30">
<div align="left">
<input name="informatica_excel" type="checkbox" id="informatica_excel" value="S">
</div></td>
<td> <div align="left">Excel</div></td>
<td width="30">
<div align="left">
<input name="informatica_access" type="checkbox" id="informatica_access" value="S">
</div></td>
<td> <div align="left">Access</div></td>
</tr>
<tr align="left">
<td width="30"><div align="left">
<input name="informatica_powerpoint" type="checkbox" id="informatica_powerpoint" value="S">
</div></td>
<td> <div align="left">Powerpoint</div></td>
<td width="30"><div align="left">
<input name="informatica_internet" type="checkbox" id="informatica_internet" value="S">
</div></td>
<td> <div align="left">Internet</div></td>
<td width="30"><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td width="167" valign="top"> Outros? Quais:</td>
<td width="279"><textarea name="informatica_outros" cols="25" rows="2" id="textarea4"></textarea></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr valign="middle" >
<td height="0" colspan="3"> <h3>Mobilidade</h3></td>
</tr>
<tr align="right" valign="middle" >
<td height="0" colspan="3" ><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td width="160" align="left"> Carta de Condução:</td>
<td width="230" ><div align="left">
<table width="180" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="30"><input type="radio" name="carta_conducao" value="S"></td>
<td> Sim</td>
<td width="30"><input type="radio" name="carta_conducao" value="N"></td>
<td> Não</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> Carta de Mota:</td>
<td width="230" ><div align="left">
<table width="180" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="30"><input type="radio" name="carta_mota" value="S"></td>
<td> Sim</td>
<td width="30"><input type="radio" name="carta_mota" value="N"></td>
<td> Não</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td align="left"> Sabe andar de patins?</td>
<td ><div align="left">
<table width="180" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="30"><input type="radio" name="andar_patins" value="S"></td>
<td> Sim</td>
<td width="30"><input type="radio" name="andar_patins" value="N"></td>
<td> Não</td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
<tr valign="middle" >
<td height="0" colspan="3"> <h3>Constituição Fisica </h3></td>
</tr>
<tr align="right" valign="middle" class="table_form">
<td colspan="3"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td width="80"> <div align="left">Altura:</div></td>
<td><div align="left">
<input name="medidas_altura" type="text" id="medidas_altura" size="3">
</div></td>
<td width="80"> <div align="left">Saia/Calça:</div></td>
<td><div align="left">
<input name="medidas_saia" type="text" id="medidas_saia" size="2">
</div></td>
</tr>
<tr>
<td width="80"><div align="left"></div></td>
<td><div align="left"></div></td>
<td width="80"><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<td width="80"> <div align="left">Casaco:</div></td>
<td><div align="left">
<input name="medidas_casaco" type="text" id="medidas322" size="2">
</div></td>
<td width="80"> <div align="left">Sapato:</div></td>
<td><div align="left">
<input name="medidas_sapato" type="text" id="medidas422" size="2">
</div></td>
</tr>
</table></td>
</tr>
<tr valign="middle" >
<td height="0" colspan="3" ><h3>Disponibilidade</h3></td>
</tr>
<tr valign="middle" class="tables">
<td height="0" colspan="3"><select name="disponibilidade" id="select">
<option value="" selected>- Escolher -</option>
<option value="Total">Total</option>
<option value="Semana">Semana</option>
<option value="Fim-de-semana">Fim-de-semana</option>
<option value="Manhã">Manhã</option>
<option value="Tarde">Tarde</option>
</select></td>
</tr>
<tr valign="middle" >
<td height="0" colspan="3"><h3>Linguas</h3></td>
</tr>
<tr valign="middle" >
<td colspan="3" align="right" ><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td align="left"><strong>Inglês</strong></td>
<td align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_ingles" value="S" onClick="showObjects('lingua_ingles_1','lingua_ingles_2','lingua_ingles_3');"></td>
<td width="50"> Sim</td>
<td width="20"><input type="radio" name="lingua_ingles" value="N" onClick="hideObjects('lingua_ingles_1','lingua_ingles_2','lingua_ingles_3');"></td>
<td> Não</td>
<td width="20"> </td>
<td> </td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td align="left"> </td>
<td align="center"><div align="left"></div></td>
</tr>
<tr id="lingua_ingles_1">
<td width="160" align="left"> Escrita:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_ingles_escrita" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_ingles_escrita" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_ingles_escrita" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_ingles_2">
<td width="160" align="left"> Conversação:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_ingles_conversa" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_ingles_conversa" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_ingles_conversa" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_ingles_3">
<td width="160" align="left"> Leitura:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="table_form">
<tr>
<td width="20"><input type="radio" name="lingua_ingles_leitura" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_ingles_leitura" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_ingles_leitura" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
</table></td>
</tr>
<tr valign="middle">
<td colspan="3" align="right" ><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td align="left"><strong>Françês</strong></td>
<td align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_frances" value="S" onClick="showObjects('lingua_frances_1','lingua_frances_2','lingua_frances_3');"></td>
<td width="50"> Sim</td>
<td width="20"><input type="radio" name="lingua_frances" value="N" onClick="hideObjects('lingua_frances_1','lingua_frances_2','lingua_frances_3');"></td>
<td> Não</td>
<td width="20"> </td>
<td> </td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td align="left"> </td>
<td align="center"><div align="left"></div></td>
</tr>
<tr id="lingua_frances_1">
<td width="160" align="left"> Escrita:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_frances_escrita" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_frances_escrita" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_frances_escrita" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_frances_2">
<td width="160" align="left"> Conversação:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_frances_conversa" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_frances_conversa" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_frances_conversa" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_frances_3">
<td width="160" align="left"> Leitura:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_frances_leitura" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_frances_leitura" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_frances_leitura" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
</table></td>
</tr>
<tr valign="middle" >
<td colspan="3" align="right"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td align="left"><strong>Alemão</strong></td>
<td align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_alemao" value="S" onClick="showObjects('lingua_alemao_1','lingua_alemao_2','lingua_alemao_3');"></td>
<td width="50"> Sim</td>
<td width="20"><input type="radio" name="lingua_alemao" value="N" onClick="hideObjects('lingua_alemao_1','lingua_alemao_2','lingua_alemao_3');"></td>
<td> Não</td>
<td width="20"> </td>
<td> </td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td align="left"> </td>
<td align="center"><div align="left"></div></td>
</tr>
<tr id="lingua_alemao_1">
<td width="160" align="left"> Escrita:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_alemao_escrita" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_alemao_escrita" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_alemao_escrita" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_alemao_2">
<td width="160" align="left"> Conversação:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="llingua_alemao_conversa" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_alemao_conversa" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_alemao_conversa" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_alemao_3">
<td width="160" align="left"> Leitura:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_alemao_leitura" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_alemao_leitura" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_alemao_leitura" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
</table></td>
</tr>
<tr valign="middle">
<td colspan="3" align="right" ><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td align="left"><b>Espanhol</b></td>
<td align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_espanhol" value="S" onClick="showObjects('lingua_espanhol_1','lingua_espanhol_2','lingua_espanhol_3');"></td>
<td width="50"> Sim</td>
<td width="20"><input type="radio" name="lingua_espanhol" value="N" onClick="hideObjects('lingua_espanhol_1','lingua_espanhol_2','lingua_espanhol_3');"></td>
<td> Não</td>
<td width="20"> </td>
<td> </td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td align="left"> </td>
<td align="center"><div align="left"></div></td>
</tr>
<tr id="lingua_espanhol_1">
<td width="160" align="left"> Escrita:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_espanhol_escrita" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_espanhol_escrita" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_espanhol_escrita" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_espanhol_2">
<td width="160" align="left"> Conversação:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_espanhol_conversa" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_espanhol_conversa" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_espanhol_conversa" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_espanhol_3">
<td width="160" align="left"> Leitura:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_espanhol_leitura" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_espanhol_leitura" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_espanhol_leitura" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
</table></td>
</tr>
<tr valign="middle" >
<td colspan="3" align="right" ><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td> </td>
<td align="center"> </td>
</tr>
<tr>
<td align="left"><strong>Italiano</strong></td>
<td align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_italiano" value="S" onClick="showObjects('lingua_italiano_1','lingua_italiano_2','lingua_italiano_3');"></td>
<td width="50"> Sim</td>
<td width="20"><input type="radio" name="lingua_italiano" value="N" onClick="hideObjects('lingua_italiano_1','lingua_italiano_2','lingua_italiano_3');"></td>
<td> Não</td>
<td width="20"> </td>
<td> </td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td align="left"> </td>
<td align="center"><div align="left"></div></td>
</tr>
<tr id="lingua_italiano_1">
<td width="160" align="left"> Escrita:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_italiano_escrita" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_italiano_escrita" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_italiano_escrita" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_italiano_2">
<td width="160" align="left"> Conversação:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_italiano_conversa" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_italiano_conversa" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_italiano_conversa" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_italiano_3">
<td width="160" align="left"> Leitura:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_italiano_leitura" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_italiano_leitura" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_italiano_leitura" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"> </td>
</tr>
</table></td>
</tr>
<tr valign="middle" >
<td colspan="3" align="left" ><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tables">
<tr>
<td> </td>
<td align="center"> </td>
</tr>
<tr>
<td align="left"><strong>Outra</strong></td>
<td align="center"><table width="200" border="0" align="left" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_outra" value="S" onClick="showObjects('lingua_outra_1','lingua_outra_2','lingua_outra_3','lingua_outra_4');"></td>
<td width="50"> Sim</td>
<td width="20"><input type="radio" name="lingua_outra" value="N" onClick="hideObjects('lingua_outra_1','lingua_outra_2','lingua_outra_3','lingua_outra_4');"></td>
<td> Não</td>
</tr>
</table></td>
</tr>
<tr>
<td align="left"> </td>
<td align="center"> </td>
</tr>
<tr id="lingua_outra_1">
<td align="left"> Qual?</td>
<td><input name="lingua_outra_nome" type="text" id="outras2" size="25" maxlength="25"></td>
</tr>
<tr>
<td align="left"> </td>
<td align="center"> </td>
</tr>
<tr id="lingua_outra_2">
<td width="160" align="left"> Escrita:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_outra_escrita" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_outra_escrita" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_outra_escrita" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_outra_3">
<td width="160" align="left"> Conversação:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_outra_conversa" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_outra_conversa" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_outra_conversa" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"><div align="left"></div></td>
</tr>
<tr id="lingua_outra_4">
<td width="160" align="left"> Leitura:</td>
<td width="230" align="center"><div align="left">
<table width="200" border="0" cellpadding="0" cellspacing="0" class="opcoes">
<tr>
<td width="20"><input type="radio" name="lingua_outra_leitura" value="bom"></td>
<td> Bom</td>
<td width="20"><input type="radio" name="lingua_outra_leitura" value="regular"></td>
<td> Regular</td>
<td width="20"><input type="radio" name="lingua_outra_leitura" value="noções"></td>
<td> Noções</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="160" align="left"> </td>
<td width="230"> </td>
</tr>
</table></td>
<tr valign="middle" class="table_form">
<td height="0" colspan="3" class="table_form" ><h3>Anexe uma foto de corpo inteiro e uma de rosto. As imagens não podem ter mais de 500kb. </h3></td>
</tr>
<tr valign="middle" class="table_form">
<td height="0" colspan="3" class="table_form" >
<table width="100%" border="0" cellpadding="0" class="tables">
GreyHead 10 Jul, 2007
Hi cleocadio,

That's a big form!

I'm not a JavaScript expert but I don't see a submit button there so what's triggering the JavaScript?

ChronoForms changes the form name. If you call it 'myform' in the Admin you'll need 'ChronoContact_myform' in your JavaScript call.

Could this be the problem?

Bob
Max_admin 10 Jul, 2007
Hi,

Yes, the only trick is where do you call the function "checkForm(ChronoContact_urformname)" and how do you write it ? whats your form name at the backend ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 10 Jul, 2007
Hi Cleocadio,

I looked at the page - thanks for the link.

There is no onsubmit code there you need to add something like onSubmit="return checkform(ChronoContact_teste1)" in the "Form Tag attachment" box on the ChronoForms "general" tab.

More seriously the JavaScript isn't appearing either, nor is the ChronoForms form footer code (though maybe you've removed that).

Perhaps there is a typo in the JavaScript that's causing this. I'll look later today.

Bob
GreyHead 10 Jul, 2007
Hi Cleocadio,

The JavaScript looks OK as far as I can tell.

But the html you posted here is not the same as the form on the Hospedeiras page - it stops before the file uploads. Please can you copy the final section from the ChronoForms 'Form HTML' box.

Thanks

Bob
cleocadio 10 Jul, 2007
Hi Bob,

I've updated the html code up there.

On the general tab now i put this: onSubmit="return checkform(ChronoContact_teste1)"

On the javascript tab i put this on start: function checkForm(ChronoContact_teste1) {...

it still sends without validation, and since i removed the enctype="multipart/form-data", it doesn't send the files.
GreyHead 10 Jul, 2007
Hi Cleocadio,

I have to go out know but will look later.

You can put both 'enctype' & 'onsubmit' instructions in the same input box - just leave a space between them. ChronoForms just pastes whatever is here into the submit input.

Bob
Max_admin 11 Jul, 2007
on the javascript tab leave it as it was before, only change what was in the onSubmit

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cleocadio 11 Jul, 2007
ok, now is: function checkForm(form) {...

Still nothing happens, i just have to put the auth code and there it goes, no questions, nada.
Fellyboy 12 Jul, 2007
Once again - hello all

I've the same problem. Now tested all you discussed in this topic - no success :woohoo:

My HTML-Code for the submit-button:
<input value="senden" name="submit" type="submit" onSubmit="checkForm(ChronoContact_Kontaktformular)">


The JS-Code:
<!--
function checkForm(ChronoContact_Kontaktformular)
{
 if(document.Formular.name.value == ""«»)  {
   alert("Bitte Ihren Namen eingeben!"«»);
   document.Formular.User.focus();
   return false;
  }
}
//-->


And my Chronoformname: Kontaktformular

Maybe that I can't see the wood due to the trees🙂

Thanks for the help!

Regards
Markus
GreyHead 12 Jul, 2007
Hi Markus,

I got this working OK!!

In the 'Form tag attachment' put
onSubmit="return checkForm(ChronoContact_KontaktFormular)"
(I got this wrong earlier - onSubmit only works in the form tag)

In 'Form HTML' put
onSubmit="return checkForm(ChronoContact_KontaktFormular)" 
In 'Form JavaScript' put
function checkForm(Formular)
{
 if(Formular.name.value == "" )  {
   alert("Bitte Ihren Namen eingeben!" );
   Formular.User.focus();
   return false;
  }
}
Note that we're passing the Form Name 'ChronoContact_KontaktFormular' to the JavaScript through the checkForm(ChronoContact_KontaktFormular) function call. In the JavaScript we can then use the 'Formular' variable (without the document. prefix).

Bob<br><br>Post edited by: GreyHead, at: 2007/07/12 17:11
Fellyboy 12 Jul, 2007
Hy Bob

Thanks for your reply! I modified the form name and entered the code as you posted it (form tag, html and script). I also use the mambot to implement the chronoform in joomla content. Could it be a problem due to this?!

My new entries:
Form name: ChronoContact_KontaktFormular
Form tag attachement: onSubmit="return checkForm(ChronoContact_KontaktFormular)"
HTML:
<input value="senden" name="submit"
 onsubmit="return checkForm(ChronoContact_KontaktFormular)"
 type="submit">


JS:
function checkForm(Formular)
{
 if(Formular.name.value == "" )  {
   alert("Bitte Ihren Namen eingeben!" );
   Formular.User.focus();
   return false;
  }
}


I also tested it "directly". Means with a menulink to the form - without content.

All mails are sent - but the check don't work.

JavaScript is activ - in IE 7.0 and Firefox 2.0.0.4.
GreyHead 13 Jul, 2007
Hi Markus,

There is nothing here to be checked. Your JavaScript checks the 'name' field and there isn't one so it is behaving correctly. Try this in the 'Form HTML' field:
<input type='text' name='name' value ='' />
<input value="senden" name="submit" type="submit" />
Bob

PS You don't need the 'onSubmit . . .' here.<br><br>Post edited by: GreyHead, at: 2007/07/12 20:07
Fellyboy 13 Jul, 2007
Hy

Oh yes of course! Sorry for that😉

But unfortunately it also won't work with your modified code.

I filled in your 2 codelines into "Form HTML". And the onsubmit - section isn't in the html field.

Greetings
GreyHead 13 Jul, 2007
Hi Markus,

In the Form Name put 'KontaktForumular' (ChronoForms adds the 'ChronoContact_' part)

In the 'Form tag attachment' field put
onSubmit="return checkForm(ChronoContact_KontaktFormular)"


Bob<br><br>Post edited by: GreyHead, at: 2007/07/12 21:37
Max_admin 13 Jul, 2007
Markus,

You cant use OnSubmit event in the button input, this must be in the form tag only, and to achieve this you must put it in the form tag attachement field just as Bob said!

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Fellyboy 13 Jul, 2007
Hy Max and Bod

Thanks a lot for the advice! I've deleted the onsubmit part in the Form Html. But it won't fit.

My new entries are as follow:

Form Name: KontaktFormular
Form tag attachment: onSubmit="return checkForm(ChronoContact_KontaktFormular)"

(also entered only KontaktFormular in the brackets... without success)

Form HTML: <input value="senden" type="submit" name="submit">
Form JavaScript:
function checkForm(Formular)
{
 if(Formular.name.value == "" )  {
   alert("Bitte Ihren Namen eingeben!" );
   Formular.User.focus();
   return false;
  }
}


Or do you have an example (somewhere else) that I can use and test. If it works I have the possibility to modify it...

Thanks and good night!
Markus
GreyHead 13 Jul, 2007
Hi Markus,

You wrote: "But it won't fit." I don't understand this.

Here's what to do:

1) Form Name: KontaktFormular

2) Form tag attachment :
onSubmit="return checkForm(ChronoContact_KontaktFormular)"
3) Form HTML :
<input type='text' name='name' value ='' />
<input value="senden" name="submit" type="submit" />
4) Form JavaScript :
function checkForm(Formular)
{
 if(Formular.name.value == ""«»)  {
   alert("Bitte Ihren Namen eingeben!"«»);
   Formular.User.focus();
   return false;
  }
}
5) the result is



That's all!

Bob<br><br>Post edited by: GreyHead, at: 2007/07/13 00:15
Fellyboy 13 Jul, 2007
Hello

Oh, I've an idea - you tested it on your localhost (as I can see on your script-popup). I tested it directly on the webserver. I had the problem that the mails wheren't sent on my localhost. So that's why I changed to the webserver.
Maybe that my changes and modifications wont take affect. I will modify all entries on my localhost and then upload all on the server.

I've to test that - maybee I have time this evening...

Markus
Fellyboy 13 Jul, 2007
Yes yes it works!

It was my fault! I had two fields with the name "name" in the HTML-code. That's why the script didn't worked.

The popup with the message appears if noting is insered into a essential field. If i click ok, the popup closes and the mail is sent anyway. No chance to enter something in the meantime. I've to check the JS-code. I guess there's a problem

Markus<br><br>Post edited by: Fellyboy, at: 2007/07/13 09:22
GreyHead 13 Jul, 2007
Hi Markus,

I don't have any e-mail on localhost either - I have a little hack in the code for debugging that creates the html message on the return page (you can see it on some of the images here). That gives me instant feedback without waiting for the e-mail to arrive.

I don't know JavaScript very well, what is below looks OK to me. The 'onSubmit="return checkForm(ChronoContact_KontaktFormular)"' should only give the 'Submit' command if the JavaSCript returns 'true'.

Bob
cleocadio 13 Jul, 2007

ok, now is: function checkForm(form) {...

Still nothing happens, i just have to put the auth code and there it goes, no questions, nada.



Hey, i still don't know what to do.


How about if i sent you the html file original where this was as attachment here?
This topic is locked and no more replies can be posted.