Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003

    Unanswered: Server side empty field validation

    I have form page, which is used to update a database.

    I want to validate the data, and rather do it on the server.

    If there's a blank field then add I want to add something like error=1 to a querystring; if there are 2 errors, then only add 2 error variables to the querystring; if there are 3, add 3 to the querystring:

    update?error=1&error=2&error=3&session(idvalue)=wh atever

    This will enable me to highlight each field which requires data on the form page

    I have to do this way 'cos if the user keeps missing a form field then at least they don't start from scratch i.e. all form fields empty.

    started working on the code:

    const numFields = 5
    dim errorArray()
    redim errorArray("error"+numfields)
    FOR EACH field in request.form
    IF Len(request.form(field)) = 0 THEN
    <a href = "update_record.asp?<%errorArray&idvalue="& Session("idvalue")%>">click here</a>
    <%END IF
    Any ideas?

  2. #2
    Join Date
    Nov 2003
    Christchurch, New Zealand
    Since you are already using the session object why not store your errors in there rather then passing them around??

  3. #3
    Join Date
    Jun 2003
    Or instead of redirecting with a querystring you may want to post the page to itself:

    ASP Design Tips - Post Back Page

    Otherwise you might want to add every field to the querysting so that the user doesn't have to start from scratch (but what a pain).
    J. Paul Schmidt, Freelance Web and Database Developer
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts