I'm trying to develop a order form that item has to be fill only with the multiple quantity of package.
e.g. Package with 20 units
Only accept package multiple quantity otherwise show me an alert message.
My problem is, my code is not working for other lines, only the first one, and this is the point that I need your help guys.
I would like to made an alert that looking for every line, not the first only.
P.S. I'm not an expert in javascript by the way, i have knowledge of php/html and I read a lot in a few forums and take some explanations from everywhere and join everything in my code.
I appreciate all of you for any help!
Here is my code.
$("#Quantity").focusout(function(){
var X = $('#package').val();
$("#Quantity").blur(function() {
var number = parseInt($(this).val());
if (!isNaN(number)) {
if (number % X === 0) {
$("#output").html("It is multiple of " + X );
} else {
$("#output").html("Not multiple of " + X );
}
} else {
$("#output").html("Entry is not a number.");
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Quantity:
<input type="text" id="Quantity">
Package:
<input type="text" id="package" value="20">
<br><br>
Quantity:
<input type="text" id="Quantity">
Package:
<input type="text" id="package" value="30">
<p id="output"></p>