radio button with text field validation

B

Bruce

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.
 
E

Evertjan.

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);
 
D

Dr J R Stockton

In comp.lang.javascript message <1ss2p5pjuct2sukfctensbejkfvb4jkhrc@4ax.
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top