SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to check : user must fill data and click checkbox

    I have many text box and many check box

    how to check that user musht fill integer in all text box and check at least 1 checkbox from many checkbox

    if he not check or fill numbeic, show pop up to warn him

    Code:
    <form action="process.php">
    <input type=text name=quantity[]>
    <input type=text name=quantity[]>
    <input type=text name=quantity[]>
    <input type=text name=quantity[]>
    <!-- more text box-->
    <input type=checbox name="qid[]" value="1">
    <input type=checbox name="qid[]" value="2">
    <input type=checbox name="qid[]" value="3">
    <input type=checbox name="qid[]" value="4">
    <!-- more check box -->
    <input type=submit name=submit>
    </form>
    Last edited by itsource; Dec 5, 2002 at 20:31.
    I live in Thailand. My English grammar not well.

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <script>
    function CheckFields()
    {
    if(Fields are OK) // Put your field check here...
    {
    return true;
    }
    else
    {
    alert("Invalid data - please re-enter")
    return false;
    }
    }
    </script>

    <form onSubmit="return CheckFields();">
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use fValidate! Below is an example of how easy it is to use. Once you have downloaded the two files, and maybe make a few changes to fValConfig.js, all the code in red is all you need to add
    Code:
    <html>
    <head>
    <title>Example</title>
    <script type="text/javascript" src="fValConfig.js"></script>
    <script type="text/javascript" src="fValidate.js"></script>
    </head>
    
    <body>
    
    <form action="process.php" onsubmit="return validateForm(this,0,1,0,0);">
    <input type="text" name="quantity[]" alt="number" />
    <input type="text" name="quantity[]" alt="number" />
    <input type="text" name="quantity[]" alt="number" />
    <input type="text" name="quantity[]" alt="number" />
    <!-- more text box-->
    <input type="checbox" name="qid[]" value="1" alt="checkbox|1|999" />
    <input type="checbox" name="qid[]" value="2">
    <input type="checbox" name="qid[]" value="3">
    <input type="checbox" name="qid[]" value="4">
    <!-- more check box -->
    <input type="submit" name="Submit">
    </form>
    
    </body>
    </html>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





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
  •