radio button with text field validation

Discussion in 'Javascript' started by Bruce, Mar 5, 2010.

  1. Bruce

    Bruce Guest

    Is there a way to tie radio button validation with a text field?

    I have a group of radio buttons. If the last one is selected, the
    following text field must have something. If any other button is
    selected, that text field could be blank.
    Bruce, Mar 5, 2010
    #1
    1. Advertising

  2. Bruce

    Evertjan. Guest

    Bruce wrote on 05 mrt 2010 in comp.lang.javascript:

    > Is there a way to tie radio button validation with a text field?
    >
    > I have a group of radio buttons. If the last one is selected, the
    > following text field must have something. If any other button is
    > selected, that text field could be blank.


    The testing for content should be done serverside or onsubmit.

    The visibility and the clearing of the field
    could be done someway like this:

    var myFormEl = document.forms['myform'].elements;

    function testRadio5() {
    myFormEl['myInput'].style.display =
    (myFormEl['myRadios'][5])
    ? '' : 'none';
    if (!(myFormEl['myRadios'][5]))
    myFormEl['myInput'].value='';
    };

    setInterval(testRadio5,200);

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Mar 5, 2010
    #2
    1. Advertising

  3. In comp.lang.javascript message <1ss2p5pjuct2sukfctensbejkfvb4jkhrc@4ax.
    com>, Fri, 5 Mar 2010 16:12:59, Tim Slattery <>
    posted:
    >Bruce <> wrote:
    >
    >>Is there a way to tie radio button validation with a text field?
    >>
    >>I have a group of radio buttons. If the last one is selected, the
    >>following text field must have something. If any other button is
    >>selected, that text field could be blank.

    >
    >This is a text input field? It should be validated server-side.


    Pages containing JavaScript do not necessarily use server-side
    processing.

    Input should be validated client-side as far as is practical.

    If data is sent to a server, then it must be validated there as far as
    is necessary.

    If the data is sent merely in order that the server shall return other
    data, server-side validation need not be so stringent as when the data
    is important to the system "behind" the server.

    The OP probably means that "if selected, non-blank" applies at submit
    time. An alternative might be that the last button will be hidden or
    disabled or cleared whenever the field is empty or blank.

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    Proper <= 4-line sig. separator as above, a line exactly "-- " (RFCs 5536/7)
    Do not Mail News to me. Before a reply, quote with ">" or "> " (RFCs 5536/7)
    Dr J R Stockton, Mar 8, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hiten
    Replies:
    1
    Views:
    609
    Vidar Petursson
    May 26, 2004
  2. Frank

    text field control by radio button

    Frank, Feb 9, 2004, in forum: ASP General
    Replies:
    0
    Views:
    125
    Frank
    Feb 9, 2004
  3. mitch-co2
    Replies:
    2
    Views:
    269
    mitch-co2
    Feb 22, 2005
  4. PeeZee
    Replies:
    1
    Views:
    105
  5. jr
    Replies:
    3
    Views:
    408
Loading...

Share This Page