Solved

Textarea validation

Posted on 2004-03-30
6
278 Views
Last Modified: 2010-05-18
hi...i can't seem to validate textarea..

function TextAreaRequired(Form, Field)
{
  var length = eval("document." + Form + "." + Field    + ".value.length");
if (length == 0)
      {return false;}
      else
      {return true;}
}
if (!TextAreaRequired(FormName, 'Work_Scope'))
{
alert("You must enter your job scope");
return false;
}
</script>


<textarea name="Work_Scope" rows="5" cols="44" wrap="virtual">[Enter your job title, scope etc. Max. 255 characters]</textarea></td>

What is wrong with this? Thanks!
0
Comment
Question by:knighto
  • 4
  • 2
6 Comments
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10720460
<form name="FormName">
<textarea name="Work_Scope" rows="5" cols="44" wrap="virtual">[Enter your job title, scope etc. Max. 255 characters]
</textarea>
</form>

<script>

function TextAreaRequired(Form, Field)
{
  var length = eval("document." + Form + "." + Field    + ".value");
  if (length == 0)
      {return false;}
     else
      {return true;}
}
if (!TextAreaRequired("FormName", 'Work_Scope'))
{
alert("You must enter your job scope");
}
</script>
0
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10720465

first of all FormName is not a variable.......
and then you are using the formname variable before the form is created...
0
 

Author Comment

by:knighto
ID: 10720634

er...there is an error when i click on submit....

Error:'document.FormName.Work_Scope' is null or not an object

Code:0

there is also a page is not displayed error.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10720743

Check the variable name....
Post the code... I will take a look
0
 

Author Comment

by:knighto
ID: 10720971
<script>
function TextAreaRequired(Form, Field)
{
  var length = eval("document." + Form + "." + Field    + ".value");
  if (length == 0)
      {return false;}
     else
      {return true;}
}
if (!TextAreaRequired(FormName,"Work_Scope"))
{
alert("You must enter your job scope");
}
</script>

<cfform name="FormName" action="Student_RegistrationAction3.cfm" method="post">

<tr class="normal">
      <td colspan="2">
        <textarea name="Work_Scope" rows="5" cols="44" wrap="virtual">[Enter your job title, scope etc. Max. 255 characters]</textarea></td>
            </tr>
                <tr>
        <td align="right" colspan="2">
      <input type="reset" value="Clear">
      <input type="submit" value="Add">
      </td>
      </tr>
0
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 30 total points
ID: 10721076
<cfform name="FormName" action="Student_RegistrationAction3.cfm" method="post">

should be

<form name="FormName" action="Student_RegistrationAction3.cfm" method="post">
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now