SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Apr 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with conditional form validation

    Greetings,

    The validation I'd like to have happen on the form on this page:

    http://www.mouseworksmedia.com/cios/...itform-pg3.htm

    is if a user enters any info in a field (say the first name field) then all fields for only that specific row would be required.

    Not being a true scripter, I would appreciate any detailed help.

    Thanks much

    --Marc (themice)

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,161
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    logic operators

    Hi themice, welcome to the forums,
    The main problem isn't writing the script, it's getting the logic you need right.
    eg. if this and this but not that or that then this and this etc.
    BTW the link you posted is no good.

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi themice,

    Welcome to SPF!

    Your link doesn't work. Please repost it. Look in the lower-left of this page for the "vB code" link. That page will tell you how to use the URL code.

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mittineague

    I didn't see your post before I posted

  5. #5
    SitePoint Member
    Join Date
    Apr 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, sorry for the broken link...
    here it is again - hope this works...

    Sample Form

    This form is for adding information on a row by row basis. Sometimes users will have 1 or 2 rows of data, sometimes none, sometimes many rows. Each row of data is unique. If it's easier to create the validation script / logic so it's based on one field (like first name) I think that would work.

    So if the user enters a first name then all fields in that specific row would be required.

    thanks for any help,

    --Marc

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,161
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    logic

    That should be fairly easy for you. Something like (in pseudocode)
    if (first is not empty) and (last is empty or year is empty or highest is empty or from is empty or status is empty) then not valid, else all required fields have been filled out. Then if it makes it past that validate the individual fields to ensure they're the correct type and format ie. name, year, and school.
    If it makes it past that, maybe add the row to an array.
    What have you got for code so far?

  7. #7
    SitePoint Member
    Join Date
    Apr 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mittineague,

    thx for the reply... I'm not versed in js - just know how to take some example scripts and try and munge them to my purposes, but only simple scripts..

    here's the link to a pre-written validation script I'm using:
    validation script example

    I don't understand most of it but know how to set up my html page & form so it works to validate any field where the name has a * in it such as: <input name="*fname" type="text" <snip>

    -- Marc

    ps. I'm just outside of Hartford, so just a long stones throw to W. Springfield :-)


Bookmarks

Posting Permissions

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