pessoal, eu tenho um botão q é uma imagem. só q quando eu clico nela não acontece nada.
olha como estou fazendo?
<img alt="Submit" src="bt_enviar.gif" value="ok" onclick="validar()" style="cursor: pointer;">
e no form eu chamo action =" pagina.asp" normal.
só q eu não sei pq parou de funcionar, antes funcionava perfeito, naum mexi em nada.
alguém me ajude.
Imagem Botão, O Q Pode Ser?
Started By rafa-martin, 24/10/2005, 12:01
4 replies to this topic
#1
Posted 24/10/2005, 12:01
#2
Posted 24/10/2005, 12:08
cade a função validar()?
#3
Posted 24/10/2005, 12:16
aqui :
<script language="JavaScript" text="text/javascript">
function trim(str)
{
return str.replace(/^\s*|\s*$/g,"");
}
function validar()
{
var i;
var flag = false;
var flag_radio = true;
var flag_check = true;
var input = document.getElementsByTagName("input");
var text = document.getElementsByTagName("textarea");
document.getElementById("resultado").innerHTML = " ";
for(i = 0; i< input.length; i++)
{
if(input[i].type == "text")
{
if(trim(input[i].value) == "" && input[i].obrigatorio == 1)
{
document.getElementById("resultado").innerHTML += '- O campo '+ input[i].name +' não foi preenchido. <br /> ';
flag = true;
}
}
else
{
if(input[i].type == "radio")
{
if(input[i].checked == true && input[i].obrigatorio == 1)
{
flag_radio = false;
}
}
else
{
if(input[i].type == "checkbox")
{
if(input[i].checked == true && input[i].obrigatorio == 1)
{
flag_check = false;
}
}
}
}
}
for(i = 0; i< text.length; i++)
{
if(trim(text[i].innerText) == "" && text[i].obrigatorio == 1)
{
document.getElementById("resultado").innerHTML += '- O campo '+ text[i].name +' não foi preenchido. <br />';
flag = true;
}
}
if(flag_radio)
{
document.getElementById("resultado").innerHTML += ' - Os campos tipos e situação não foram selecionados. <br />';
}
/* if(flag_check)
{
document.getElementById("resultado").innerHTML += 'Nenhum campo checkbox não foi selecionado. <br />';
} */
if((flag == false) /*&& (flag_radio == false)*/)
{
Visitas.submit();
}
}
</script>
<script language="JavaScript" text="text/javascript">
function trim(str)
{
return str.replace(/^\s*|\s*$/g,"");
}
function validar()
{
var i;
var flag = false;
var flag_radio = true;
var flag_check = true;
var input = document.getElementsByTagName("input");
var text = document.getElementsByTagName("textarea");
document.getElementById("resultado").innerHTML = " ";
for(i = 0; i< input.length; i++)
{
if(input[i].type == "text")
{
if(trim(input[i].value) == "" && input[i].obrigatorio == 1)
{
document.getElementById("resultado").innerHTML += '- O campo '+ input[i].name +' não foi preenchido. <br /> ';
flag = true;
}
}
else
{
if(input[i].type == "radio")
{
if(input[i].checked == true && input[i].obrigatorio == 1)
{
flag_radio = false;
}
}
else
{
if(input[i].type == "checkbox")
{
if(input[i].checked == true && input[i].obrigatorio == 1)
{
flag_check = false;
}
}
}
}
}
for(i = 0; i< text.length; i++)
{
if(trim(text[i].innerText) == "" && text[i].obrigatorio == 1)
{
document.getElementById("resultado").innerHTML += '- O campo '+ text[i].name +' não foi preenchido. <br />';
flag = true;
}
}
if(flag_radio)
{
document.getElementById("resultado").innerHTML += ' - Os campos tipos e situação não foram selecionados. <br />';
}
/* if(flag_check)
{
document.getElementById("resultado").innerHTML += 'Nenhum campo checkbox não foi selecionado. <br />';
} */
if((flag == false) /*&& (flag_radio == false)*/)
{
Visitas.submit();
}
}
</script>
#4
Posted 24/10/2005, 16:07
Dê uma olhada nessa linha:
Existe a função trim?
input[i].obrigatorio ?
if(trim(input[i].value) == "" && input[i].obrigatorio == 1)
Existe a função trim?
input[i].obrigatorio ?
Eduardo Batista
#5
Posted 25/10/2005, 14:48
Voce quer uma imagem que funcione como um botão submit?
<img alt="Submit" src="bt_enviar.gif" value="ok" onclick="java script:forms.submit" style="cursor: pointer;">
Talvez não funcione. Pesquize por algo do tipo, é a maneira mais simples de se fazer
<img alt="Submit" src="bt_enviar.gif" value="ok" onclick="java script:forms.submit" style="cursor: pointer;">
Talvez não funcione. Pesquize por algo do tipo, é a maneira mais simples de se fazer
Quer uma boa promoção?
Cadastre seu cliente em nossa hospedagem, ganhe 50% do valor no primeiro mês e a partir daí 10% a 15% do valor mensal!
Para entrar em contato por e-mail - webmaster@almagus.com.br ou www.almagus.com.br ou MP.
Cadastre seu cliente em nossa hospedagem, ganhe 50% do valor no primeiro mês e a partir daí 10% a 15% do valor mensal!
Para entrar em contato por e-mail - webmaster@almagus.com.br ou www.almagus.com.br ou MP.
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)