473,325 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Check for minimum quantity?

Hi All

I have a form, with a few input boxes (number of input boxes can vary). Each
input box has a name such as in1, in3, in7, etc (their names can be in any
order, although increasing).
I want to make a javascript function to check if the quantity a user fills
into each of the input boxes is over a minimum value (different for every
input box). Any ideas how can I do this?

Regards,
Nicoale


Jul 26 '05 #1
2 2084
Lee
Nicolae Fieraru said:

Hi All

I have a form, with a few input boxes (number of input boxes can vary). Each
input box has a name such as in1, in3, in7, etc (their names can be in any
order, although increasing).
That's a direct contradiction. I think you mean that the order
is always increasing, but that they may not be sequential.
I want to make a javascript function to check if the quantity a user fills
into each of the input boxes is over a minimum value (different for every
input box). Any ideas how can I do this?


Since you don't know how many there are, I assume that the page
is being generate by software. Simply have that same software
generate a literal data object to control the audit (the variable
"minVal" in this example). If possible, you might also have the
code produce meaningful variable names.
<html>
<head>
<title>Demo</title>
<script type="text/javascript">
var minVal = [
{ name: "in1", min: 18, desc: "Your age" },
{ name: "in3", min: 6, desc: "Shoe size" },
{ name: "in7", min: 8, desc: "Hours requested" }
];

function checkMins(f) {
var msg="";
for (var i=0;i<minVal.length;i++) {
if(+f.elements[minVal[i].name].value < minVal[i].min) {
msg+="\n"+minVal[i].desc+" must be at least " +minVal[i].min;
}
}
if(msg) {
alert(msg);
return false;
}
return true;
}
</script>
</head>
<body>
<form name="foo" onsubmit="return checkMins(this)">
<input name="in1"><input name="in3"><input name="in7"><input type="submit">
</form>
</body>
</html>
Jul 26 '05 #2
>>I have a form, with a few input boxes (number of input boxes can vary).
Each
input box has a name such as in1, in3, in7, etc (their names can be in any
order, although increasing).


That's a direct contradiction. I think you mean that the order
is always increasing, but that they may not be sequential.


Thank you Lee, I know it was a contradiction, but I couldn't remember the
term "sequential" :-)

The piece of software you kindly provided works perfectly and I will use
your idea in my asp page. Thank you very much for your help.

Best wishes,
Nicolae
Jul 26 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shannan Casteel via AccessMonster.com | last post by:
I have a subform for listing parts. It has fields including: ClaimID, ITEM, NET PRICE, LIST PRICE, Quantity, Supplier, and a calculated field called Part Total. The subform is based on a query. ...
2
by: Shannan Casteel via AccessMonster.com | last post by:
I have a subform for listing parts. It has fields including: ClaimID, ITEM, NET PRICE, LIST PRICE, Quantity, Supplier, and a calculated field called Part Total. The subform is based on a query. ...
3
by: Shannan Casteel via AccessMonster.com | last post by:
I have a subform for listing parts. It has fields including: ClaimID, ITEM, NET PRICE, LIST PRICE, Quantity, Supplier, and a calculated field called Part Total. The subform is based on a...
2
by: Shannan Casteel via AccessMonster.com | last post by:
I have a simple invoice form with a subform that allows the user to list part numbers along with the quantity. The subform has a calculated field called that should take either the or the and...
2
by: Abhishek Srivastava | last post by:
Hello All, Can I validate the minimum length of a field using any of the existing validators? I searched google on this subject and found people offering custom controls for this. However,...
5
by: HandersonVA | last post by:
should I set to "0" as a default value on a quantity and a price field or set to "null"? if a user enter nothing on the quantity or price field on a web browser, should I treat it as null or "0"?...
13
by: HockeyFan | last post by:
I'm not sure how to exactly ask this, but expect that it's a Javascript solution. However, I'll ask the question and maybe someone can point me to some existing code that will do what I need. I...
14
by: kang jia | last post by:
hi i am doing shopping online, i will let user choose their prodcut in the first page and then when they click" order" button, they will be redirected to do_addcart.php. i will insert their orders...
6
by: balach | last post by:
i want to check in minimum possible time by transfering minimum data to other system to check that the sytem is running or it is off. For example: i have IP Address: 198.162.11.200 and i want to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.