SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Required Fields - HTML Form

    How do I make certain fields required in my simple contact form. I guess I also need to know how to display a message to fill out ALL fields if the user tries to send the form without doing so.

    Thanks in advance

    Kit

  2. #2
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use Javascript to check upon form submit that all appropriate values are filled in, but that will fail if the user has JS turned off. Other than that you will have to rely on server-side scripting, like PHP to check.
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  3. #3
    SitePoint Zealot Crey_Design's Avatar
    Join Date
    Oct 2008
    Location
    Scottsdale, AZ
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have Dreamweaver, there is a series of tools called Spry that will very easily let you make your contact fields required.

    If not, simply search "javascript, form field required" and you'll get tons of results.
    Chris Reynolds
    Crey Design
    Arizona Web Design
    Personal Blog

  4. #4
    SitePoint Evangelist bals28mjk's Avatar
    Join Date
    Aug 2007
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I usually do is run two scripts, one for JavaScript (client-side) and another for PHP (server-side). Client-side validation is good if your interested in user friendliness and bandwidth, though not required. Server-side validation you have to do unless you'll get a gaping security hole. Possibility said and implied most of this, but I thought it would go good if I followed with my thoughts as well.

    If you want help in writing the actual scripts your probably best asking advice for the code in the client-side/server-side scripting forums that we've made mention.

    Hope that helps, cheers.

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys

  6. #6
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well,

    Server-side validation is a must. Absence of it is a huuge security vulnerability.

    JavaScript validation is not required for security but is good for user-friendliness and to save some little bandwidth.


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
  •