If input type text not null must check (select) radio button

  • xmsmmgrs
  • Beginner
  • Beginner
  • xmsmmgrs
  • Posts: 50

Post 3+ Months Ago

I have a text box where people can enter the title of a book.
If a title is entered they MUST choose if they are the author or not.

I don`t know how to do the MUST part.

If the "title" box is empty they have nothing to do with the radio buttons.

If a "title" is entered, they must choose if they are "author" or "not author".

It would be great if we could show the radio buttons only if a title is entered.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Title</title>
    <style type="text/css">
    label {display:block;}
    #author_box {visibility:hidden;}
    </style>
    <script type="text/javascript">
    function abox(state)
    {
        document.getElementById('author_box').style.visibility = state;
    }
    </script>
</head>
<body>
    <fieldset>
        <legend>Book</legend>
        <p>I want to include a book I am &hellip;</p>
        <label onclick="abox('hidden')">
            <input type="radio" name="is_author" value="0" checked="checked"/>&nbsp;nevermind, no book
        </label>
        <label onclick="abox('visible')">
            <input type="radio" name="is_author" value="author"/>&nbsp;the author of
        </label>
        <label onclick="abox('visible')">
            <input type="radio" name="is_author" value="non-author"/>&nbsp;not the author of
        </label>
        <label id="author_box">
            Book Title :<input type="text" name="title" value=""/>
        </label>
    </fieldset>
</body>
</html>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4.     <title>Title</title>
  5.     <style type="text/css">
  6.     label {display:block;}
  7.     #author_box {visibility:hidden;}
  8.     </style>
  9.     <script type="text/javascript">
  10.     function abox(state)
  11.     {
  12.         document.getElementById('author_box').style.visibility = state;
  13.     }
  14.     </script>
  15. </head>
  16. <body>
  17.     <fieldset>
  18.         <legend>Book</legend>
  19.         <p>I want to include a book I am &hellip;</p>
  20.         <label onclick="abox('hidden')">
  21.             <input type="radio" name="is_author" value="0" checked="checked"/>&nbsp;nevermind, no book
  22.         </label>
  23.         <label onclick="abox('visible')">
  24.             <input type="radio" name="is_author" value="author"/>&nbsp;the author of
  25.         </label>
  26.         <label onclick="abox('visible')">
  27.             <input type="radio" name="is_author" value="non-author"/>&nbsp;not the author of
  28.         </label>
  29.         <label id="author_box">
  30.             Book Title :<input type="text" name="title" value=""/>
  31.         </label>
  32.     </fieldset>
  33. </body>
  34. </html>

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 34 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.