0
It’s an automated keyboard that once I type the 6 digits it executes the form taking the numbers typed in a php variable to another page, but when I click on the first number it already executes the form..
<form id="Form" action="action.php" method="post">
<div id="fields">
<div class="grid">
<div contenteditable="true" name="textBox" class="grid__col grid__col--1-of-6 numberfield"><span></span></div>
<div contenteditable="true" name="textBox" class="grid__col grid__col--1-of-6 numberfield"><span></span></div>
<div contenteditable="true" name="textBox" class="grid__col grid__col--1-of-6 numberfield"><span></span></div>
<div contenteditable="true" name="textBox" class="grid__col grid__col--1-of-6 numberfield"><span></span></div>
<div contenteditable="true" name="textBox" class="grid__col grid__col--1-of-6 numberfield"><span></span></div>
<div contenteditable="true" name="textBox" class="grid__col grid__col--1-of-6 numberfield"><span></span></div>
</div>
</div>
<div id="numbers">
<div class="grid">
<div class="grid__col grid__col--1-of-3"><button>1</button></div>
<div class="grid__col grid__col--1-of-3"><button>2</button></div>
<div class="grid__col grid__col--1-of-3"><button>3</button></div>
<div class="grid__col grid__col--1-of-3"><button>4</button></div>
<div class="grid__col grid__col--1-of-3"><button>5</button></div>
<div class="grid__col grid__col--1-of-3"><button>6</button></div>
<div class="grid__col grid__col--1-of-3"><button>7</button></div>
<div class="grid__col grid__col--1-of-3"><button>8</button></div>
<div class="grid__col grid__col--1-of-3"><button>9</button></div>
<div class="grid__col grid__col--1-of-3"></div>
<div class="grid__col grid__col--1-of-3"><button>0</button></div>
<div class="grid__col grid__col--1-of-3"></div>
</div>
</div>
</form>
</div>
</div>
jQuery(document).ready(function($) {
$(document).ready(function() {
var enterCode = "";
enterCode.toString();
$("#numbers button").click(function() {
var clickedNumber = $(this).text().toString();
enterCode = enterCode + clickedNumber;
var lengthCode = parseInt(enterCode.length);
lengthCode--;
$("#fields .numberfield:eq(" + lengthCode + ")").addClass("active");
});
});
});
$(function() {
$('#textBox').bind('change keyup', function() {
if ($(this).val().length >= 6) {
$('#Form').submit();
}
})
});
already its click Function, passes to it the event:
$("#numbers button").click(function(event) {
and and within the method cancel the event to avoid Submit with the commandevent.preventDefault();
. See if you solve, want I can post a reply explaining– Ricardo Pontual
Please, I’m a beginner if you could make an example would be really good @Ricardopunctual
– Julio Alves
I can do it, but in the meantime test those changes I commented on
– Ricardo Pontual
beauty, I will test, but I wanted to take the value too and send it as variable php in the form for action.php
– Julio Alves
I tested it and it still continues, when I click it makes the Submit
– Julio Alves
take a look at this example with your code, it does not Ubmit by clicking the https://jsfiddle.net/c2tp4hmsbuttons/
– Ricardo Pontual
But there in the div grid, I type 6 numbers until he runs the Ubmit, that’s what I wanted, and take these numbers typed in a variable for the next page
– Julio Alves