checking for nothing entered in an asp form post

Discussion in 'ASP General' started by wk6pack, Jul 1, 2005.

  1. wk6pack

    wk6pack Guest

    Hi,

    How do you check for a empty value from a form?

    lservice = request.form("pservice")

    if not isnull(lservice) then <== this doesnt work.
    tried "" empty string and it still didnt work.
    ......

    I'm having problems with the fact the user didnt enter anything. The field
    is optional.

    thanks,
    Will
     
    wk6pack, Jul 1, 2005
    #1
    1. Advertising

  2. wk6pack wrote:
    > Hi,
    >
    > How do you check for a empty value from a form?
    >
    > lservice = request.form("pservice")
    >
    > if not isnull(lservice) then <== this doesnt work.
    > tried "" empty string and it still didnt work.
    > .....
    >
    > I'm having problems with the fact the user didnt enter anything. The
    > field is optional.
    >
    > thanks,
    > Will


    form and querystring variables contain strings, so just check the number of
    characters:

    if len(lservice) > 0 then


    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jul 1, 2005
    #2
    1. Advertising

  3. wk6pack

    Roland Hall Guest

    "wk6pack" wrote in message news:...
    : How do you check for a empty value from a form?
    :
    : lservice = request.form("pservice")
    :
    : if not isnull(lservice) then <== this doesnt work.
    : tried "" empty string and it still didnt work.
    : .....
    :
    : I'm having problems with the fact the user didnt enter anything. The
    field
    : is optional.

    This works also:

    if lserver <> "" then
    ' value present
    else
    ' no value present
    end if

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Jul 1, 2005
    #3
  4. wk6pack

    Bullschmidt Guest

    And here are some server-side validation links:

    Server-Side Form Validation by Dianna Leech - 12/1/1999
    http://www.4guysfromrolla.com/webtech/120199-1.shtml

    An Email Validation Routine by João Vieira - 4/11/1999
    http://www.4guysfromrolla.com/webtech/041199-1.shtml
    Somewhat shorter.

    An Email Validation Script by Ben Durbin - 5/19/1999
    http://www.4guysfromrolla.com/webtech/051999-1.shtml
    Longer.

    Form Handler: Some light form validation and error notification.
    http://www.asp101.com/samples/form_handler.asp
    Uses function to loop thru all fields in a form.

    And some client-side ones:

    Javascript Field Validations -- Client Side Scripting by Nannette
    Thacker - 8/19/1999
    http://www.shiningstar.net/articles/articles/javascript/javascriptvalida
    tions.asp?ID=AW

    Form Validation Using Javascript - 9/19/1998
    http://www.4guysfromrolla.com/webtech/091998-1.shtml
    Good tips such as saving JavaScript functions in a file called
    DataValidation.js and including this in pages that need this.
    JavaScript functions.

    WebDaily: Your daily source for Web Technology Tips and Tricks! -
    10/27/1998
    http://www.4guysfromrolla.com/webtech/102798-1.shtml
    Just checks if fields filled in.

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    http://www.Bullschmidt.com
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex http://www.developersdex.com ***
     
    Bullschmidt, Jul 5, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith
    Replies:
    4
    Views:
    757
    DalePres
    May 2, 2004
  2. hansiman

    Comparing dates entered from a form

    hansiman, Jun 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    348
    Raterus
    Jun 4, 2004
  3. TN Bella
    Replies:
    1
    Views:
    1,534
    TN Bella
    Jul 1, 2004
  4. Devin Jeanpierre
    Replies:
    2
    Views:
    513
    Devin Jeanpierre
    Feb 14, 2012
  5. Luke Matuszewski
    Replies:
    8
    Views:
    145
    Luke Matuszewski
    Apr 22, 2006
Loading...

Share This Page