Solved

JavaScript to validate form for less than 10 characters

Posted on 2011-03-01
2
247 Views
Last Modified: 2012-05-11
The JavaScript below works when the form is empty but I also want to check another condition if the value is less then 10. How do I do this with my example code?
<SCRIPT language="JavaScript">
function validateForm(form) {

   if (form.TITLE.value == "") {
      alert("Your title is empty.");
      return false
   }
   
   if (form.STORY_BODY.value == "") {
      alert("Please enter story.");
      return false
   }

   return true
}

</SCRIPT>

Open in new window

0
Comment
Question by:Qsorb
[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
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35013806
Use : form.STORY_BODY.value.length < 10
<SCRIPT language="JavaScript">
function validateForm(form) {

   if (form.TITLE.value == "") {
      alert("Your title is empty.");
      return false
   }
   
   if (form.STORY_BODY.value.length < 10) {
      alert("Please enter story.");
      return false
   }

   return true
}

</SCRIPT>

Open in new window

0
 

Author Closing Comment

by:Qsorb
ID: 35013822
Great. And thanks. That was certainly quick.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses

632 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