SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    min number of fields check

    I have a form with multiple values that I need to validate. Most are pretty simple, but one of the validation rules are stumping me.

    I have 5 zip code fields. (zip1, zip2, zip3, zip4, zip5). I would like to check to see if the user has filled in at least three of the fields. Ie, the user needs to fill in 3 to 5 zip codes.

  2. #2
    SitePoint Enthusiast w!ll's Avatar
    Join Date
    May 2008
    Location
    Bucharest, Romania
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do that with javascript: http://www.w3schools.com/js/js_form_validation.asp
    Gumball 3000 Rally Pictures
    Adauga site (Web Directory - only for romanian websites)

  3. #3
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I know how to do simple form validation with javascript, but not checking if at least 3 out of 5 text fields have been filled in.

    ie.. there are other fields: name,address, city, state....

    However, there are 5 zip fields and the user needs to fill in at least 3 of the 5. So if they fill in 0, one, or two of the fields, an error would occur.


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
  •