SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,416
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Ensuring the form-filler, fills in a particular section ?

    Using formmail cgi (yep, I know about the weaknesses with the script, but can't seem to find another way, without involving php), I can ensure that, if the person doesn't complete an input section for their name, address etc, the next page after clicking the 'send' button tells them which fields they have missed, but how do you do it for a select option like below please ?

    Code:
    <SELECT style="text" name="Input">
    <OPTION>Desired rank of film</OPTION> 
    <OPTION>1</OPTION> 
    <OPTION>2</OPTION> 
    <OPTION>3</OPTION>
    </SELECT>
    Any help appreciated.

    Dez.

  2. #2
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,416
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Anyone know who the mod is on this section please ?

    Thanks.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,607
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Test the value of the field. If the value corresponds to the first entry then they haven't selected anything.

    If you actually add value attributes to the options you make it easier because you can use value=" " for the message option and then just test that the value passed isn't a space.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,416
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Thanks Stephen, is that using anyhting to do with php please ? Anywhere on the net that I can see examples of this please ?

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,607
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    HTML Code:
    <SELECT style="text" name="Input">
    <OPTION VALUE=" ">Desired rank of film</OPTION> 
    <OPTION VALUE="1">1</OPTION> 
    <OPTION VALUE="2">2</OPTION> 
    <OPTION VALUE="3">3</OPTION>
    </SELECT>
    and

    PHP Code:
    if ($_POST['Input'] == ' ') {
    echo 
    'You fogot to select a film rank';

    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,416
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    I like the sound of that Stephen, but there's already some php code that has to go at the very top of the page, would this interfere with that please ?

  7. #7
    Mouse catcher silver trophy
    Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,835
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    Roll on the days when we can just put the required attribute (from HTML5) on the input - it works on Opera 10 but I don't think it works on much else at the moment!


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
  •