"Claire Osborne" <cl****@interface-web.co.uk> wrote in message
news:12**************************@posting.google.c om...
I have created a form at
http://www.habitatforhumanity.org.uk...ndiv_apply.htm
In the Medical Details section we need to ensure that if a radio
button is clicked to indicate a health issue then the textarea box is
filled in.
Is there a way to do this?
I am not an expert in Javascript so please treat me as stupid!
Thanks.
Here's a function that will identify which textareas are blank when there
corresponding radiobutton is "yes".
function radiotext() {
var form = document.application;
var errs = "";
for (i=0; i<form.elements.length; i++) {
if (form.elements[i].type == "radio") {
if (form.elements[i].value == "yes") {
if (form.elements[i].checked) {
if (form.elements[i+1].value == "") {
errs += "\n" + form.elements[i+1].name;
}
}
}
}
}
if (errs != "") {
alert("Please enter:\n" + errs);
return false;
}
return true;
}
It can be called by adding the following line to the "form" tag:
onsubmit="return radiotext()"