Link to home
Start Free TrialLog in
Avatar of GreatPlains
GreatPlains

asked on

Creating a Maxlength for Multiple Textareas

I have a couple text boxes in a form.  They both require a different amount of lengths.  It reads the one javascript to check it, but not for the second textarea.  How do I get both of them to work.

Here is my Code:

<script language="javascript" type="text/javascript">
<!--
function validate() {
      maxlength=1000;
      if(document.myForm.ldesc.value.length>=maxlength) {
            alert('Your Long Description must be 1000 characters or less');
            document.myForm.ldesc.focus();
            return false;
      } else {
            return true;
      }
}

function validate1() {
      maxlength=250;
      if(document.myForm.bdesc.value.length>=maxlength) {
            alert('Your Brief Description must be 250 characters or less');
            document.myForm.bdesc.focus();
            return false;
      } else {
            return true;
      }
}
//-->
</script>

Here is the form Action:
<cfform name="myForm" action="submitMod2.cfm" method="post" enctype="multipart/form-data" onsubmit="return validate(); return validate1();" >
ASKER CERTIFIED SOLUTION
Avatar of Tomarse111
Tomarse111
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GreatPlains
GreatPlains

ASKER

I had tried that before and couldn't get it working, but It is now.

Thanks