Solved

Textarea validation

Posted on 2004-03-30
6
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

696 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