<ko******@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
I have a very simple webpage (html form). There are about 50 input
textboxes and users are expected to insert data. No I would like to
know how in javascript I can check the values in all textboxes not to
exceed 1000 in total. I want to click the button that submits the data
on the server, to fire a javascript check the values and if less than
1000 then send them over otherwrise popup a message window and say
values exceed 1000.
Thanks a lot
Marios Koumides
Will this help? Watch for word-wrap.
<html>
<head>
<title>max1000.htm</title>
<script type="text/javascript">
function bytes() {
var max = 0;
for (var i=0; i<document.forms[0].elements.length; i++) {
if (document.forms[0].elements[i].type == "text") {
max += document.forms[0].elements[i].value.length;
}
}
window.status = max;
if (max <= 1000) return true;
alert("1,000 character maximum exceeded!");
return false;
}
</script>
</head>
<body>
<form onsubmit="return bytes()">
<input type="text" name="t001" value="" onblur="bytes()">
<input type="text" name="t002" value="" onblur="bytes()">
</form>
</body>
</html>