Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 596791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:12:36+00:00 2026-05-13T16:12:36+00:00

here is the code sample: HTML: <form id=information name=information action=# method=post> <textarea name=text rows=10

  • 0

here is the code sample:
HTML:

 <form id="information" name="information" action="#" method="post"> 
 <textarea name="text" rows="10" cols="10"> 
 </textarea> 
 <input type="submit" value="submit"/> 
 </form> 

Javascript:

 window.onload=init;

 function init(){
 document.getElementById('information').onsubmit=validateForm;
 }

 function validateForm(){ 
 var text= document.information.text.value; 
 if(text==""){ 
 alert('text area cannot be empty');
 return false;
 } 
 }

it does not work…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:12:37+00:00Added an answer on May 13, 2026 at 4:12 pm

    The textarea has a carriage return in it (and a space), so your condition is never true. So change it to:

    <textarea name="text" rows="10" cols="10"></textarea> 
    

    However you may want to go further and stop the user entering an “empty” response (meaning nothing but white-space). Or you may just want to remove leading and trailing white-space. If so you can do this:

    text = text.trim();
    

    Now trim() I believe is relatively new (Firefox lists it as new in 3.5). A more backwards compatible version is:

    text = text..replace(/^\s\s*/, '').replace(/\s\s*$/, '');
    

    and then testing if it’s empty.

    Faster JavaScript Trim has a good analysis on various white-space trimming alternatives. For instance the above can be done with one regex:

    text = text..replace(/^\s+|\s+$/g, '');
    

    but

    This commonly thought up approach is
    easily the most frequently used in
    JavaScript libraries today. It is
    generally the fastest implementation
    of the bunch only when working with
    short strings which don’t include
    leading or trailing whitespace. This
    minor advantage is due in part to the
    initial-character discrimination
    optimization it triggers. While this
    is a relatively decent performer, it’s
    slower than the three methods above
    when working with longer strings,
    because the top-level alternation
    prevents a number of optimizations
    which could otherwise kick in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 315k
  • Answers 315k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Wikipedia API does support JSONP. Your query string'll become… May 13, 2026 at 11:18 pm
  • Editorial Team
    Editorial Team added an answer We cannot modify the access modifiers when overriding a virtual… May 13, 2026 at 11:18 pm
  • Editorial Team
    Editorial Team added an answer I'm pretty sure that command is used by the individual… May 13, 2026 at 11:18 pm

Related Questions

I'm trying to iterate over checkboxes in an ASP.Net web page, and if any
I am trying to deal with an IE7 bug in my application. Here is
here is the sample code: from mechanize import Browser br = Browser() page =
Is the only difference between the RegisterStartupScript and the RegisterClientScriptBlock is that RegisterStartupScript puts
I am sure sure if this is even possible due to the nature of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.