SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form Validation Help Needed Please

    I am knew here so hi to everyone, I have been told by a friend that this site is particularly helpful so here goes.

    I have a form that i want to ensure is filled out correctly before the user is able to proceed. I am also advised that Javascript is the easiest way to do this, however i have no idea how to implememnt it.

    http://chimp.cc/start.htm

    If the user fails to fill out the terms and conditions box with a "Yes"when the user clicks submit, i want a message to pop up to tell them to complete it.

    and to return the user to that field for completion.

    I honestly have no idea how to do this, can someone please help me.

    I have attached the source code too.

    Cheers

    Andy
    Attached Files Attached Files

  2. #2
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're looking to do a quick, client-side validation (I recommend server-side validation as well), you can call a JavaScript function when the "Submit" button is clicked or with the onsubmit form event that checks the value of that field:
    HTML Code:
    function checkTerms() {
      var box = document.getElementById("terms");
      if (box.toUpperCase() !== "YES") {
        alert("You must agree to the terms for this to work");
        return false;
      } else {
        return true;
      }
    }
    Hopefully you get the idea. It also looks like you tried using some sort of built-in dreamweaver extension to provide form validation?

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an excellent resource on Javascript and Forms:http://www.quirksmode.org/js/forms.html


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
  •