|
Postada em 03/05/2004 10:10 hs
Alguém tem uma função pra impedir que o usuário digite os caracteres "<" e ">" em um text area . . . preciso inibir apenas estes caracteres . . . mas não tô conseguindo ! ! !
|
|
|
|
|
Postada em 03/05/2004 16:25 hs
a tecla < = 60 a tecla < = 62 use a rotina abaixo e faça seus ifs retornando falso se for 60 ou 62. -------------- <html> <head> <title>Pegar a tecla ENTER</title> </head> <body> <script language="JavaScript" type="text/javascript"> //Função p/ verificar se usuário digitou a tecla ENTER. function PegarEnter() { if(document.all) // Internet Explorer var Tecla = event.keyCode; else if(document.layers) //Nestcape var Tecla = e.which; if(Tecla == 13) alert("Vc. pressionou enter!!"); else return false; } document.onkeypress = PegarEnter; </script> </body> </html>
http://www.vilmarbro.com.br
|
|
|
|
Postada em 03/05/2004 17:21 hs
Muito boa vilmar . . . eu tinha achado isso aqui em baixo . . . mas só funciona no IE . . .
<html><head> <script language="JavaScript">
function keyPress(tecla) { var pKey = tecla.keyCode;
if(pKey==60 || pKey==62) { alert("Caracter inválido!"); return false; } }
</script>
</head> <body>
<input type=text onkeypress="return keyPress(event);">
</body> </html>
Valew . . . vou testar este exemplo . . . espero que não seja CrossBrowser 
|
|
|
Márcio Puntel
não registrado
|
|
Postada em 06/05/2004 08:32 hs
Cara essas funções em javascript não sei muito bem, mas eu resolveria em asp fazendo um replace("<",""), assim apagaria o sinal.
|
|
|
|
Postada em 14/05/2004 12:26 hs
rodrigo, para funcionar no netscape use o que está acima: if(document.all) // Internet Explorer var Tecla = event.keyCode; else if(document.layers) //Nestcape var Tecla = e.which; márcio, eu acho melhor dá um replace pelos códigos literais dos sinais < e >: varx = replace(varx,"<","<") varx = replace(varx,">",">") t+
http://www.vilmarbro.com.br
|
|
|