form validation problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: form validation problem

  1. #1
    LucyG Guest

    form validation problem


    I'm trying to check for zero length strings entered into a <textarea> element
    (using vbscript in ASP).

    I've tried:

    if body = "" then...

    and also

    if len(body)=0 then...

    (The var "body" comes from a textarea in my form.)

    Now either of these methods work fine for checking whether "title" is a zero
    length string. But then "title" comes from a <input type=text>, not a <textarea>
    element.

    Can anyone help, please..?


  2. #2
    Devin Knutson Guest

    Re: form validation problem

    "LucyG" <rumanraisin@hotmail.com> wrote in message
    news:3c639b03$1@10.1.10.29...
    >
    > I'm trying to check for zero length strings entered into a

    <textarea> element
    > (using vbscript in ASP).


    When checking for zero length strings, always remember to trim
    leading and trailing spaces first since the space character will
    count as being part of the string.

    For instance,

    strTest = " "
    Len(strTest) 'Returns 1

    'With leading and trailing spaces trimmed:
    Len(Trim(strTest)) 'Returns 0

    Hope this helps!

    --
    Devin
    ========================================================



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center