Force
06-25-2003, 09:08 AM
I have created the following two scripts. When I run them in my internal development environment (CF Studio 5.0), they both work fine. When I run them in in my browser (IE 6), the checkexist() function gets stuck in an endless loop on the first textarea only.
For example, if I tab without making an entry in the first textarea I get the alert box. I click on it, and I immediately get the alert box again. I'm not given a chance to make an entry in the block. It seems to work fine for the second block.
Any ideas?
I appreciate the assistance. Thanks.
Mark F.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Length Validation</title>
<script language=javascript>
function checkLength(size,controlStr) {
var maxlen = size
var val = document.myform[controlStr].value
var diff = val.length - size
if (val.length > size) {
alert("You have exceeded the maximum length of " + maxlen + " by " + diff + " characters.\n Please modify your entry.\n Thank you.")
val = val.substr(1, maxlen)
document.myform[controlStr].focus();
}
}
</script>
<script language="JavaScript">
function checkexist(contStr) {
var control = document.myform[contStr].value
if (control.length == 0) {
alert('This is a required field. \n Please verify your entry.\n Thank you.');
document.myform[contStr].focus();
}
}
</script>
</head>
<body>
<form action="testscriptact.cfm" method="post" name="myform">
<textarea name="test1" rows="5" cols="45" onblur="checkLength(15,'test1');checkexist('test1');"></textarea>
<br><br>
<textarea name="test2" rows="5" cols="45" onblur="checkLength(25,'test2');checkexist('test2');"></textarea>
<input type="submit" name="Submit">
</form>
</body>
</html>
For example, if I tab without making an entry in the first textarea I get the alert box. I click on it, and I immediately get the alert box again. I'm not given a chance to make an entry in the block. It seems to work fine for the second block.
Any ideas?
I appreciate the assistance. Thanks.
Mark F.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Length Validation</title>
<script language=javascript>
function checkLength(size,controlStr) {
var maxlen = size
var val = document.myform[controlStr].value
var diff = val.length - size
if (val.length > size) {
alert("You have exceeded the maximum length of " + maxlen + " by " + diff + " characters.\n Please modify your entry.\n Thank you.")
val = val.substr(1, maxlen)
document.myform[controlStr].focus();
}
}
</script>
<script language="JavaScript">
function checkexist(contStr) {
var control = document.myform[contStr].value
if (control.length == 0) {
alert('This is a required field. \n Please verify your entry.\n Thank you.');
document.myform[contStr].focus();
}
}
</script>
</head>
<body>
<form action="testscriptact.cfm" method="post" name="myform">
<textarea name="test1" rows="5" cols="45" onblur="checkLength(15,'test1');checkexist('test1');"></textarea>
<br><br>
<textarea name="test2" rows="5" cols="45" onblur="checkLength(25,'test2');checkexist('test2');"></textarea>
<input type="submit" name="Submit">
</form>
</body>
</html>