Jump to content
Fórum Script Brasil
  • 0

Como Arrumar


black power

Question

bom pessoal qro ajuda de vc´s

seria basicamente isso

tenho un formulario com campos text qria pular quando apertasse enter

so não tah fumfum

o enter ele cadastra!

q seria

<script language=javascript>

function handleEnter (field, event) {

var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

if (keyCode == 13) {

var i;

for (i = 0; i < field.form1.elements.length; i++)

if (field == field.form1.elements)

break;

i = (i + 1) % field.form1.elements.length;

field.form1.elements.focus();

return false;

}

else

return true;

}

</script><input name="txtNome" type="text" id="txtNome" value="" size="35" onkeypress="return handleEnter(this, event)">

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

<html>

<head>

<title>Muda Campo com Enter</title>

<style type="text/css">

BODY {

scrollbar-arrow-color:000000;

scrollbar-track-color:f2f2f2;

scrollbar-shadow-color:cccccc;

scrollbar-face-color:ffffff;

scrollbar-highlight-color:ffffff;

scrollbar-darkshadow-color:000000;

scrollbar-3dlight-color:e2e2e2;

}

.titulo {font-family :verdana; font-size:14; color:white}

.texto {font-family :verdana; font-size:12; color:darkblue}

.alert {font-family :arial; font-size:16; color:green}

.codigo {font-family :verdana; font-size:11; color:#000000}

.h, A.h:link, A.h:visited, A.h:hover {font-family :verdana; font-size:11; color:#000000}

A.h:hover {color: red}

.h1, A.h1:link, A.h1:visited, A.h1:hover {font-family :verdana; font-size:11; color:#ffffff}

A.h1:hover {color: skyblue}

.box {

border-top:1px solid #000000;

border-bottom:1px solid #000000;

border-left:1px solid #000000;

border-right:1px solid #000000;

font-family:arial;

font-size:12px;

color: 000000;

background-color:#ffffff;

}

</style>

<script LANGUAGE="JavaScript">

<!-- Begin

nextfield = "campo1"; // nome do primeiro campo do site

netscape = "";

ver = navigator.appVersion; len = ver.length;

for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;

netscape = (ver.charAt(iln+1).toUpperCase() != "C");

function keyDown(DnEvents) {

// ve quando e o netscape ou IE

k = (netscape) ? DnEvents.which : window.event.keyCode;

if (k == 13) { // preciona tecla enter

if (nextfield == 'done') {

alert("Os campos estão em branco !");

return false;

//return true; // envia quando termina os campos

} else {

// se existem mais campos vai para o proximo

eval('document.form1.' + nextfield + '.focus()');

return false;

}

}

}

document.onkeydown = keyDown; // work together to analyze keystrokes

if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);

// End -->

</script>

</head>

<body>

<form action="" method="post" name="form1" onSubmit="return checa(this);">

<center>

<table border="0" cellspacing="0" cellpadding="0" width="50%">

<tr>

<td class="texto">&nbsp; <b>Nome</b></td>

<td class="texto">&nbsp; <input type="text" name="campo1" size="45" onFocus="nextfield ='campo2';" class="box"></td>

</tr>

<tr>

<td class="texto">&nbsp; <b>Endereço</b></td>

<td class="texto">&nbsp; <input type="text" name="campo2" size="45" onFocus="nextfield ='campo3';" class="box"></td>

</tr>

<tr>

<td class="texto">&nbsp; <b>E-Mail</b></td>

<td class="texto">&nbsp; <input type="text" name="campo3" size="45" onFocus="nextfield ='campo4';" class="box"></td>

</tr>

<tr>

<td class="texto">&nbsp; <b>Comentários</b></td>

<td class="texto">&nbsp; <input type="text" name="campo4" size="45" onFocus="nextfield ='done';" class="box"></td>

</tr>

<tr>

<td class="texto">&nbsp;</td>

<td class="texto" align="center"><input type="submit" name="envia" value="Enviar" class="box"> &nbsp; <input type="reset" name="envia" value="Apagar" class="box"></td>

</tr>

</table>

</center>

</form>

</body>

</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.5k
×
×
  • Create New...