0
Friends what is happening is that it is passing spaces and repeated numbers, I do not know what to do :P
<form name="form" id="form" action="passo_01.php" method="post" onSubmit="return validasucesso()">
<td bgcolor="#F7F7F7" ><input name="table1" type="text" id="table1" lang="1" onKeyUp="javascript:pulacampo('table1','table2');" size="3" maxlength="4" onKeyPress="return SomenteNumero(event)" autofocus /></td>
function IsNumeric(){
myForm = document.getElementById("form");
var myArray=[];
for(i=0;i<myForm.elements.length;i++){
if(myForm.elements[i].type=='number'){
myArray[myArray.length]=myForm.elements[i].value;
}
}
myArray.sort();
for(i=0;i<myArray.length-1;i++){
if(myArray[i]==myArray[i+1]){
alert('Chaves repitidas no formulário!');
selectkey(myArray[i]);
return false;
break;
exit;
}
}
return true;
}
function validasucesso(){
var i;
var value;
for (i = 1;i <=70;i ++) {
eval("value = document.form.table" + i + ".value");
if (value.length < 4) {
alert("Cartão de segurança inválido, verifique os dígitos corretamente.");
eval("document.form.table" + i +".focus()");
return false;
}
if (IsNumeric(value)) {
}
else
{
alert("Cartão de segurança inválido, verifique os dígitos corretamente.");
eval("document.form.table" + i +".focus()");
return false;
}
}
for (i = 1;i <=70;i ++) {
eval("value = document.form.table" + i + ".value");
eval("document.form.table" + i + ".value = value");
}
}
The code posted is no test conditions! Who is Somentenumero who is Pulacampo
– user60252
@Leocaracciolo are validations that are working, I can post here for you !
– Leonardo Ribeiro
Function Somentenumero(e){ var key=(window.Event)? Event.keycode:e. which; if((key > 47 && key < 58)) Return true; Else{ if (key != 8) Return false; Else Return true; } } Function pulacampo(idobj, idproximo) { var str = new String(Document.getElementById(idobj).value); var mx = new Number(Document.getElementById(idobj).maxlength); if (str.length == mx) { Document.getElementById(idproximo). Focus(); } }
– Leonardo Ribeiro