View Full Version : Radio button validation and focus help needed

Nick Martin
12-29-2005, 08:15 PM

I am coding up a questionnaire in Domino 6.5.4. I am trying to validate all fields and when not succesful return an errror message and a subsequent focus to the field in question. Within the form there is a button that calls a dosubmit function located in the jsheader field. All works well except for two areas :

1 When trying to ensure that the a radio button has been selected (ie the question answered) the validation does not seem to be working. After many tinkerings with the syntax (value==null, checked==false) I still dont seem to be getting this to work (it either accepts the form in the browser or returns the error message advising that the field is still blank (in the case below the error is "please enter frequency"). My feeling is that my syntax is incorrect on this one so if someone could set this tired head straight it would be appreciated.

2 When returning the focus to the radio button in question in the browser it leaves out the text appearing above - essentially the question located two lines above. I realise that the focus is due to my selecting [0] -- ( [0] being the first option in the radio button). Was wondering if there was any way to get the lines above to appear. the question is in text format and not a field so I can't ask for the focus to go to that field. I would just like a little more text appearing above. the code follows below and any help would be much appreciated as I think I am getting circular and not seeing the wood for the trees !!!

JS Header :

function doSubmitForm(){

var f=document.forms[0];
if (f.FirstName.value==""){
alert("Please enter your first name");
return false;
if (Surname.value==""){
alert("Please enter your surname ");
return false;
if (loginfrequency.checked==false){
alert("Please enter frequency ");
return false;

return f.submit();

12-29-2005, 11:29 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


<script language="JavaScript" type="text/javascript">

function CheckRadio(f){
var eles=f.elements;
var names='';
var radiogrp,ck;
for (zxc0=0;zxc0<eles.length;zxc0++){
if (eles[zxc0].type=='radio'&&!names.match(eles[zxc0].name)){
for (zxc1=0;zxc1<radiogrp.length;zxc1++){
if (radiogrp[zxc1].checked){
if (!ck){
alert('check one in radio group '+eles[zxc0].name);



radio buttons of the same name form an array so must be checked using something like this if the name cannot be used<br>
<input type="radio" name="fred">
<input type="radio" name="fred">
<input type="radio" name="fred"><br>
<input type="radio" name="tom">
<input type="radio" name="tom"><br>
<input type="button" value="Check Radio" onclick="CheckRadio(this.form);" >